On this page
The SHOW CREATE VIEW
statement shows the CREATE VIEW
statement that would create a copy of the specified view.
Required Privileges
The user must have any privilege on the target view.
Synopsis
Parameters
Parameter | Description |
---|---|
view_name |
The name of the view for which to show the CREATE VIEW statement. |
Response
Field | Description |
---|---|
View |
The name of the view. |
CreateView |
The CREATE VIEW statement for creating a copy of the specified view. |
Examples
Show the CREATE VIEW
statement for a 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)
Show just a view's SELECT
statement
To get just a view's SELECT
statement, you can query the views
table in the built-in information_schema
database and filter on the view name:
> SELECT view_definition
FROM information_schema.views
WHERE table_name = 'user_accounts';
+---------------------------------------+
| view_definition |
+---------------------------------------+
| SELECT type, email FROM bank.accounts |
+---------------------------------------+
(1 row)