-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Veeupup <code@tanweime.com>
- Loading branch information
Showing
16 changed files
with
149 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
label: 'DDL for Logical View' | ||
link: | ||
type: generated-index | ||
title: 'DDL for Logical View' |
37 changes: 37 additions & 0 deletions
37
docs/doc/03-reference/03-sql/01-ddl/06-view/ddl-alter-view.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: ALTER VIEW | ||
--- | ||
|
||
Alter the existing view by using another `QUERY`. | ||
|
||
## Syntax | ||
|
||
```sql | ||
ALTER VIEW [db.]view_name AS SELECT query | ||
``` | ||
|
||
## Examples | ||
|
||
```sql | ||
mysql> create view tmp_view as select number % 3 as a, avg(number) from numbers(1000) group by a order by a; | ||
|
||
mysql> select * from tmp_view; | ||
+------+-------------+ | ||
| a | avg(number) | | ||
+------+-------------+ | ||
| 0 | 499.5 | | ||
| 1 | 499 | | ||
| 2 | 500 | | ||
+------+-------------+ | ||
|
||
mysql> ALTER VIEW tmp_view AS SELECT * from numbers(3); | ||
|
||
mysql> select * from tmp_view; | ||
+--------+ | ||
| number | | ||
+--------+ | ||
| 0 | | ||
| 1 | | ||
| 2 | | ||
+--------+ | ||
``` |
43 changes: 43 additions & 0 deletions
43
docs/doc/03-reference/03-sql/01-ddl/06-view/ddl-create-view.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: CREATE VIEW | ||
--- | ||
|
||
Create a new Logical View of a Table. The Logical View does not store any physical data, when we access a logical view, it | ||
will convert the sql into the subqery format to finish it. | ||
|
||
For example, if you create a Logical View like: | ||
|
||
```sql | ||
CREATE VIEW view_t1 AS SELECT a, b FROM t1; | ||
``` | ||
And do a query like: | ||
```sql | ||
SELECT a from view_t1; | ||
``` | ||
the result equals the below query | ||
```sql | ||
SELECT a from (SELECT a, b FROM t1); | ||
``` | ||
|
||
So, if you delete the table which the view depends on, it occurs an error that the original table does not exist. And you may need to drop the old view and recreate the new view you need. | ||
|
||
## Syntax | ||
|
||
```sql | ||
CREATE VIEW [IF NOT EXISTS] [db.]view_name AS SELECT query | ||
``` | ||
|
||
## Examples | ||
|
||
```sql | ||
mysql> create view tmp_view as select number % 3 as a, avg(number) from numbers(1000) group by a order by a; | ||
|
||
mysql> select * from tmp_view; | ||
+------+-------------+ | ||
| a | avg(number) | | ||
+------+-------------+ | ||
| 0 | 499.5 | | ||
| 1 | 499 | | ||
| 2 | 500 | | ||
+------+-------------+ | ||
``` |
20 changes: 20 additions & 0 deletions
20
docs/doc/03-reference/03-sql/01-ddl/06-view/ddl-drop-view.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: DROP VIEW | ||
--- | ||
|
||
Drop the view. | ||
|
||
## Syntax | ||
|
||
```sql | ||
DROP VIEW [IF EXISTS] [db.]view_name | ||
``` | ||
|
||
## Examples | ||
|
||
```sql | ||
mysql> DROP VIEW IF EXISTS tmp_view; | ||
|
||
mysql> select * from tmp_view; | ||
ERROR 1105 (HY000): Code: 1025, displayText = Unknown table 'tmp_view'. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.