2019-08-19 02:17:50 -04:00
|
|
|
---
|
|
|
|
layout: global
|
|
|
|
title: ALTER VIEW
|
|
|
|
displayTitle: ALTER VIEW
|
|
|
|
license: |
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
---
|
|
|
|
|
2019-11-14 15:58:32 -05:00
|
|
|
### Description
|
|
|
|
|
|
|
|
The `ALTER VIEW` statement can alter metadata associated with the view. It can change the definition of the view, change
|
|
|
|
the name of a view to a different name, set and unset the metadata of the view by setting `TBLPROPERTIES`.
|
|
|
|
|
|
|
|
#### RENAME View
|
|
|
|
Renames the existing view. If the new view name already exists in the source database, a `TableAlreadyExistsException` is thrown. This operation
|
|
|
|
does not support moving the views across databases.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
{% highlight sql %}
|
|
|
|
ALTER VIEW view_identifier RENAME TO view_identifier
|
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
#### Parameters
|
|
|
|
<dl>
|
|
|
|
<dt><code><em>view_identifier</em></code></dt>
|
|
|
|
<dd>
|
|
|
|
Specifies a view name, which may be optionally qualified with a database name.<br><br>
|
|
|
|
<b> Syntax:</b>
|
|
|
|
<code>
|
2019-12-02 10:05:40 -05:00
|
|
|
[ database_name. ] view_name
|
2019-11-14 15:58:32 -05:00
|
|
|
</code>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
#### SET View Properties
|
|
|
|
Set one or more properties of an existing view. The properties are the key value pairs. If the properties' keys exist,
|
|
|
|
the values are replaced with the new values. If the properties' keys do not exist, the key value pairs are added into
|
|
|
|
the properties.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
{% highlight sql %}
|
2019-12-02 10:05:40 -05:00
|
|
|
ALTER VIEW view_identifier SET TBLPROPERTIES ( property_key = property_val [ , ... ] )
|
2019-11-14 15:58:32 -05:00
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
#### Parameters
|
|
|
|
<dl>
|
|
|
|
<dt><code><em>view_identifier</em></code></dt>
|
|
|
|
<dd>
|
|
|
|
Specifies a view name, which may be optionally qualified with a database name.<br><br>
|
|
|
|
<b> Syntax:</b>
|
|
|
|
<code>
|
2019-12-02 10:05:40 -05:00
|
|
|
[ database_name. ] view_name
|
2019-11-14 15:58:32 -05:00
|
|
|
</code>
|
|
|
|
</dd>
|
|
|
|
<dt><code><em>property_key</em></code></dt>
|
|
|
|
<dd>
|
|
|
|
Specifies the property key. The key may consists of multiple parts separated by dot.<br><br>
|
|
|
|
<b>Syntax:</b>
|
|
|
|
<code>
|
2019-12-02 10:05:40 -05:00
|
|
|
[ key_part1 ] [ .key_part2 ] [ ... ]
|
2019-11-14 15:58:32 -05:00
|
|
|
</code>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
#### UNSET View Properties
|
|
|
|
Drop one or more properties of an existing view. If the specified keys do not exist, an exception is thrown. Use
|
|
|
|
`IF EXISTS` to avoid the exception.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
{% highlight sql %}
|
2019-12-02 10:05:40 -05:00
|
|
|
ALTER VIEW view_identifier UNSET TBLPROPERTIES [ IF EXISTS ] ( property_key [ , ... ] )
|
2019-11-14 15:58:32 -05:00
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
#### Parameters
|
|
|
|
<dl>
|
|
|
|
<dt><code><em>view_identifier</em></code></dt>
|
|
|
|
<dd>
|
|
|
|
Specifies a view name, which may be optionally qualified with a database name.<br><br>
|
|
|
|
<b> Syntax:</b>
|
|
|
|
<code>
|
2019-12-02 10:05:40 -05:00
|
|
|
[ database_name. ] view_name
|
2019-11-14 15:58:32 -05:00
|
|
|
</code>
|
|
|
|
</dd>
|
|
|
|
<dt><code><em>property_key</em></code></dt>
|
|
|
|
<dd>
|
|
|
|
Specifies the property key. The key may consists of multiple parts separated by dot.<br><br>
|
|
|
|
<b>Syntax:</b>
|
|
|
|
<code>
|
2019-12-02 10:05:40 -05:00
|
|
|
[ key_part1 ] [ .key_part2 ] [ ... ]
|
2019-11-14 15:58:32 -05:00
|
|
|
</code>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
#### ALTER View AS SELECT
|
|
|
|
`ALTER VIEW view_identifier AS SELECT` statement changes the definition of a view, the `SELECT` statement must be valid,
|
|
|
|
and the `view_identifier` must exist.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
{% highlight sql %}
|
|
|
|
ALTER VIEW view_identifier AS select_statement
|
|
|
|
{% endhighlight %}
|
|
|
|
|
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
2020-04-13 00:40:36 -04:00
|
|
|
Note that `ALTER VIEW` statement does not support `SET SERDE` or `SET SERDEPROPERTIES` properties.
|
|
|
|
|
2019-11-14 15:58:32 -05:00
|
|
|
#### Parameters
|
|
|
|
<dl>
|
|
|
|
<dt><code><em>view_identifier</em></code></dt>
|
|
|
|
<dd>
|
|
|
|
Specifies a view name, which may be optionally qualified with a database name.<br><br>
|
|
|
|
<b> Syntax:</b>
|
|
|
|
<code>
|
2019-12-02 10:05:40 -05:00
|
|
|
[ database_name. ] view_name
|
2019-11-14 15:58:32 -05:00
|
|
|
</code>
|
|
|
|
</dd>
|
|
|
|
<dt><code><em>select_statement</em></code></dt>
|
|
|
|
<dd>
|
|
|
|
Specifies the definition of the view, detail check <a href="sql-ref-syntax-qry-select.html">select_statement</a>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
|
|
|
{% highlight sql %}
|
|
|
|
-- Rename only changes the view name.
|
|
|
|
-- The source and target databases of the view have to be the same.
|
|
|
|
-- Use qualified or unqualified name for the source and target view
|
|
|
|
ALTER VIEW tempdb1.v1 RENAME TO tempdb1.v2;
|
|
|
|
|
|
|
|
-- Verify that the new view is created.
|
|
|
|
DESCRIBE TABLE EXTENDED tempdb1.v2;
|
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
2020-04-13 00:40:36 -04:00
|
|
|
+----------------------------+----------+-------+
|
|
|
|
| col_name|data_type |comment|
|
|
|
|
+----------------------------+----------+-------+
|
|
|
|
| c1| int| null|
|
|
|
|
| c2| string| null|
|
|
|
|
| | | |
|
|
|
|
|# Detailed Table Information| | |
|
|
|
|
| Database| tempdb1| |
|
|
|
|
| Table| v2| |
|
|
|
|
+----------------------------+----------+-------+
|
2019-11-14 15:58:32 -05:00
|
|
|
|
|
|
|
-- Before ALTER VIEW SET TBLPROPERTIES
|
|
|
|
DESC TABLE EXTENDED tempdb1.v2;
|
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
2020-04-13 00:40:36 -04:00
|
|
|
+----------------------------+----------+-------+
|
|
|
|
| col_name| data_type|comment|
|
|
|
|
+----------------------------+----------+-------+
|
|
|
|
| c1| int| null|
|
|
|
|
| c2| string| null|
|
|
|
|
| | | |
|
|
|
|
|# Detailed Table Information| | |
|
|
|
|
| Database| tempdb1| |
|
|
|
|
| Table| v2| |
|
|
|
|
| Table Properties| [....]| |
|
|
|
|
+----------------------------+----------+-------+
|
2019-11-14 15:58:32 -05:00
|
|
|
|
|
|
|
-- Set properties in TBLPROPERTIES
|
|
|
|
ALTER VIEW tempdb1.v2 SET TBLPROPERTIES ('created.by.user' = "John", 'created.date' = '01-01-2001' );
|
|
|
|
|
|
|
|
-- Use `DESCRIBE TABLE EXTENDED tempdb1.v2` to verify
|
|
|
|
DESC TABLE EXTENDED tempdb1.v2;
|
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
2020-04-13 00:40:36 -04:00
|
|
|
+----------------------------+-----------------------------------------------------+-------+
|
|
|
|
| col_name| data_type|comment|
|
|
|
|
+----------------------------+-----------------------------------------------------+-------+
|
|
|
|
| c1| int| null|
|
|
|
|
| c2| string| null|
|
|
|
|
| | | |
|
|
|
|
|# Detailed Table Information| | |
|
|
|
|
| Database| tempdb1| |
|
|
|
|
| Table| v2| |
|
|
|
|
| Table Properties|[created.by.user=John, created.date=01-01-2001, ....]| |
|
|
|
|
+----------------------------+-----------------------------------------------------+-------+
|
2019-11-14 15:58:32 -05:00
|
|
|
|
|
|
|
-- Remove the key `created.by.user` and `created.date` from `TBLPROPERTIES`
|
|
|
|
ALTER VIEW tempdb1.v2 UNSET TBLPROPERTIES ('created.by.user', 'created.date');
|
|
|
|
|
|
|
|
--Use `DESC TABLE EXTENDED tempdb1.v2` to verify the changes
|
|
|
|
DESC TABLE EXTENDED tempdb1.v2;
|
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
2020-04-13 00:40:36 -04:00
|
|
|
+----------------------------+----------+-------+
|
|
|
|
| col_name| data_type|comment|
|
|
|
|
+----------------------------+----------+-------+
|
|
|
|
| c1| int| null|
|
|
|
|
| c2| string| null|
|
|
|
|
| | | |
|
|
|
|
|# Detailed Table Information| | |
|
|
|
|
| Database| tempdb1| |
|
|
|
|
| Table| v2| |
|
|
|
|
| Table Properties| [....]| |
|
|
|
|
+----------------------------+----------+-------+
|
2019-11-14 15:58:32 -05:00
|
|
|
|
|
|
|
-- Change the view definition
|
|
|
|
ALTER VIEW tempdb1.v2 AS SELECT * FROM tempdb1.v1;
|
|
|
|
|
|
|
|
-- Use `DESC TABLE EXTENDED` to verify
|
|
|
|
DESC TABLE EXTENDED tempdb1.v2;
|
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
2020-04-13 00:40:36 -04:00
|
|
|
+----------------------------+---------------------------+-------+
|
|
|
|
| col_name| data_type|comment|
|
|
|
|
+----------------------------+---------------------------+-------+
|
|
|
|
| c1| int| null|
|
|
|
|
| c2| string| null|
|
|
|
|
| | | |
|
|
|
|
|# Detailed Table Information| | |
|
|
|
|
| Database| tempdb1| |
|
|
|
|
| Table| v2| |
|
|
|
|
| Type| VIEW| |
|
|
|
|
| View Text| select * from tempdb1.v1| |
|
|
|
|
| View Original Text| select * from tempdb1.v1| |
|
|
|
|
+----------------------------+---------------------------+-------+
|
2019-11-14 15:58:32 -05:00
|
|
|
{% endhighlight %}
|
|
|
|
|
|
|
|
### Related Statements
|
|
|
|
|
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
2020-04-13 00:40:36 -04:00
|
|
|
* [describe-table](sql-ref-syntax-aux-describe-table.html)
|
|
|
|
* [create-view](sql-ref-syntax-ddl-create-view.html)
|
|
|
|
* [drop-view](sql-ref-syntax-ddl-drop-view.html)
|
|
|
|
* [show-views](sql-ref-syntax-aux-show-views.html)
|