Name

SHOW CREATE VIEW

Synopsis

SHOW CREATE VIEW view

Use this statement to display an SQL statement that can be used to create a view like the one named. The results may be copied and used with another database. They also could be copied and the name of the view modified so that the statement may be used on the same database. This statement is available as of Version 5.0.1 of MySQL.

SHOW CREATE VIEW employee_directory\G
*************************** 1. row ***************************
Table:  employees
Create Table: CREATE VIEW `employee_directory`.`personnel`
              (`ID`, `Name` `Ext.`,)
              AS SELECT emp_id,
              CONCAT(emp_first, ` `, emp_last),
              tel_extension
              FROM employees;

This view is the same one that is created in the example given for the CREATE VIEW statement earlier. Notice that the database name (personnel) has been added to the end of the view name (employee_directory).

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.