SHOW CREATE VIEW 语句 用于显示创建 viewCREATE VIEW 语句。

所需权限

用户必需具有视图的任一权限

概要

图片

参数

Parameter Description
view_name 要查看CREATE VIEW语句的视图名。

返回

Field Description
View 视图名字
CreateView 创建视图的CREATE VIEW 语句

例子

查看一个视图的 CREATE VIEW 语句

> SHOW CREATE VIEW bank.user_accounts;
+--------------------+---------------------------------------------------------------------------+
|        View        |                                CreateView                                 |
+--------------------+---------------------------------------------------------------------------+
| bank.user_accounts | CREATE VIEW "bank.user_accounts" AS SELECT type, email FROM bank.accounts |
+--------------------+---------------------------------------------------------------------------+
(1 row)

查看 视图的SELECT 定义语句

通过information_schema数据库的views表,使用视图名进行过滤后,就可以找出视图的SELECT定义语句。

> SELECT view_definition
  FROM information_schema.views
  WHERE table_name = 'user_accounts';
+---------------------------------------+
|            view_definition            |
+---------------------------------------+
| SELECT type, email FROM bank.accounts |
+---------------------------------------+
(1 row)

See Also