Site icon TestingDocs.com

MySQL SHOW CREATE VIEW Statement

Overview

The SHOW CREATE VIEW statement shows a CREATE VIEW statement that creates the given view. MySQL statements that are designed to display the base table information can also be used to display the view information.

For example, the following statements also displays the views:

Syntax

The general syntax of the statement is as follows::

SHOW CREATE VIEW <view_name>

This statement displays the creation of a view from an existing table.

Example

The SHOW FULL TABLES lists the names of the tables and the views. The Table_type column displays the values that indicate the kind of object for each object. The column values are BASE TABLE, VIEW, or SYSTEM VIEW.

 

mysql> SHOW FULL TABLES;
+———————+————+
| Tables_in_worlddemo | Table_type |
+———————+————+
| city | BASE TABLE |
| country | BASE TABLE |
| countrylanguage | BASE TABLE |
| v_city | VIEW |
+———————+————+
4 rows in set (0.00 sec)

 

mysql> SHOW CREATE VIEW v_city \G

*************************** 1. row ***************************
View: v_city
Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_city` AS select `city`.`ID` AS `id`,`city`.`Name` AS `name`,`city`.`CountryCode` AS `countrycode` from `city`
character_set_client: cp850
collation_connection: cp850_general_ci
1 row in set (0.00 sec)

 

We can also obtain information about view objects from INFORMATION_SCHEMA. This schema contains a system view called VIEWS.

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version