SHOW CREATE VIEW

On this page Carat arrow pointing down
Warning:
CockroachDB v1.0 is no longer supported as of November 10, 2018. For more details, refer to the Release Support Policy.

The SHOW CREATE VIEW statement shows the CREATE VIEW statement that would create a carbon copy of the specified view.

Required Privileges

The user must have any privilege on the target view.

Synopsis

SHOW CREATE VIEW view_name

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 carbon 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)

See Also


Yes No
On this page

Yes No