Files
doris/docs/zh-CN/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-VIEW.md
Mingyu Chen 74a482ca7f [fix] fix docs build bug (#9293)
After this PR #9272, the `docs/build_help_zip.sh` will run failed.
This PR fix this issue.
But the help module still has some parse problem, I will fix it in next PR.

This CL mainly changes:
1. fix `docs/build_help_zip.sh` error
2. remove `sql-reference-v2` to `sql-reference`
3. modify build extension github action to run `docs/build_help_zip.sh`
2022-04-28 22:19:04 +08:00

1.9 KiB

title, language
title language
CREATE-VIEW zh-CN

CREATE-VIEW

Name

CREATE VIEW

Description

该语句用于创建一个逻辑视图 语法:

CREATE VIEW [IF NOT EXISTS]
 [db_name.]view_name
 (column1[ COMMENT "col comment"][, column2, ...])
AS query_stmt

说明:

  • 视图为逻辑视图,没有物理存储。所有在视图上的查询相当于在视图对应的子查询上进行。
  • query_stmt 为任意支持的 SQL

Example

  1. 在 example_db 上创建视图 example_view

    CREATE VIEW example_db.example_view (k1, k2, k3, v1)
    AS
    SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table
    WHERE k1 = 20160112 GROUP BY k1,k2,k3;
    
  2. 创建一个包含 comment 的 view

    CREATE VIEW example_db.example_view
    (
        k1 COMMENT "first key",
        k2 COMMENT "second key",
        k3 COMMENT "third key",
        v1 COMMENT "first value"
    )
    COMMENT "my first view"
    AS
    SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table
    WHERE k1 = 20160112 GROUP BY k1,k2,k3;
    

Keywords

CREATE, VIEW

Best Practice