SHOW CREATE VIEW

Returns the statement that was used to create a given view. The SHOW CREATE VIEW statement helps you understand how the view is defined and provides a reference for you to modify or reconstruct the view. Note that the SHOW CREATE VIEW statement requires you to have the SELECT privilege on the view and the table based on which the view is created.

You can use SHOW CREATE VIEW to query the statement that is used to create a materialized view.

Syntax

SHOW CREATE VIEW [db_name.]<view_name>

Parameters

ParameterRequiredDescription
db_nameNoThe database name. If this parameter is not specified, the current database is used by default.
view_nameYesThe view name.

Return

+---------+--------------+----------------------+----------------------+
| View    | Create View  | character_set_client | collation_connection |
+---------+--------------+----------------------+----------------------+

The following table describes the parameters returned by this statement.

ParameterDescription
ViewThe view name.
Create ViewThe CREATE VIEW statement of the view.
character_set_clientThe character set the client uses to send statements to CelerData.
collation_connectionThe rules for comparing characters in a character set.

Examples

Show the CREATE VIEW statement of example_view.

SHOW CREATE VIEW example_db.example_view;

+--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View         | Create View                                                                                                                                                                                                                                                                                                                     | character_set_client | collation_connection |
+--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| example_view | CREATE VIEW `example_view` (k1, k2, k3, v1) COMMENT "VIEW" AS SELECT `default_cluster:db1`.`example_table`.`k1` AS `k1`, `default_cluster:db1`.`example_table`.`k2` AS `k2`, `default_cluster:db1`.`example_table`.`k3` AS `k3`, `default_cluster:db1`.`example_table`.`v1` AS `v1` FROM `default_cluster:db1`.`example_table`; | utf8                 | utf8_general_ci      |
+--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+