SHOW CREATE VIEW

Shows the CREATE VIEW statement that was used to create the view.

Syntax

SHOW CREATE VIEW view_name

Arguments

view_name

The name of the view.

Remarks

  • The Create View field from the output can be used to recreate the view.

  • See the Permission Matrix for the required permission.

Example

The following example displays the output of SHOW CREATE VIEW.

CREATE VIEW count AS SELECT COUNT(*) FROM square WHERE num > 5;
SHOW CREATE VIEW count;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| View  | Create View                                                                                                                                      | character_set_client | collation_connection |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
| count | CREATE DEFINER=`root`@`%` SCHEMA_BINDING=OFF VIEW `count` AS SELECT COUNT(*) AS `COUNT(*)` FROM `square` as `square`  WHERE (`square`.`num` > 0) | utf8                 | utf8_general_ci      |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+

Related Topics

Last modified: December 6, 2023

Was this article helpful?