- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
As we know that views are a type of virtual tables and are the composition of tables too hence we can use the same query to get the definition of a view which we use to get the definition of a table. In other words, we can use SHOW CREATE statement to get the definition of a MySQL view. Its syntax would be as follows −
SHOW CREATE VIEW view_name;
Here view_name is the name of the view of which we want to get the definition.
The following query will give the definition of a view named ‘info’ −
mysql> Show Create View Info\G *************************** 1. row *************************** View: info Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `info` AS select `student_info`.`id` AS `ID`,`student_info`.`Name` AS `NAME`,`student_info`.`Subject` AS `SUBJECT`,`student_info`.`Address` AS `ADDRESS` from `student_info` character_set_client: cp850 collation_connection: cp850_general_ci 1 row in set (0.00 sec)
- Related Articles
- How can we get the structure of a MySQL view as we can get the structure of a MySQL table?
- How can we modify the definition of a MySQL view without dropping it?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can we update any value in MySQL view as we can update the values in MySQL table?
- How can we get the metadata of MySQL events?
- How can we get a list of columns in an existing MySQL table?
- How can we get the sorted MySQL output?
- How can we change the name of a MySQL table?
- In MySQL, how can we get the number code of a particular character?
- How can we drop a MySQL view from the database?
- How can we get “MySQL server-side help”?
- How can we get the list of MySQL server-side help categories?
- Can we get total number of rows in a MySQL database?
- How can we create a MySQL view with a subquery?
- How can we make a MySQL clone table?