Skip to content

Commit

Permalink
add create view explanation (apache#3925)
Browse files Browse the repository at this point in the history
* add create view explanation

* correct prettier check
  • Loading branch information
retikulum authored and Dandandan committed Nov 5, 2022
1 parent fd05f6b commit 84f3b33
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/source/user-guide/sql/ddl.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,39 @@ DROP TABLE users;
DROP TABLE IF EXISTS nonexistent_table;
```

## CREATE VIEW

View is a virtual table based on the result of a SQL query. It can be created from an existing table or values list.

<pre>
CREATE VIEW <i><b>view_name</i></b> AS statement;
</pre>

```sql
CREATE TABLE users AS VALUES(1,2),(2,3),(3,4),(4,5);
CREATE VIEW test AS SELECT column1 FROM users;
SELECT * FROM test;
+---------+
| column1 |
+---------+
| 1 |
| 2 |
| 3 |
| 4 |
+---------+
```

```sql
CREATE VIEW test AS VALUES(1,2),(5,6);
SELECT * FROM test;
+---------+---------+
| column1 | column2 |
+---------+---------+
| 1 | 2 |
| 5 | 6 |
+---------+---------+
```

## DROP VIEW

Removes the view from DataFusion's catalog.
Expand Down

0 comments on commit 84f3b33

Please sign in to comment.