
- 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 structure of a MySQL view as we can get the structure of a MySQL table?
As we know that views are a type of virtual tables and are a composition of tables too hence we can use the same query to get the structure of a view which we use to get the structure of a table. In other words, we can use DESCRIBE statement to get the structure of a MySQL view. Its syntax would be as follows −
Syntax
DESCRIBE view_name;
Here, view_name is the name of the view of which we want to get the structure.
Example
Suppose we want to get the structure of a view named ‘Info’ then it can be done with the help, of the following query −
mysql> DESCRIBE INFO; +---------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+-------+ | ID | int(11) | YES | | NULL | | | NAME | varchar(20) | YES | | NULL | | | SUBJECT | varchar(20) | YES | | NULL | | | ADDRESS | varchar(20) | YES | | NULL | | +---------+-------------+------+-----+---------+-------+ 4 rows in set (0.02 sec)
The above result set shows that all the fields got the same definitions as in the base table.
- Related Articles
- How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
- How can we automatically define the structure of MySQL table same as the structure of another table?
- 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 modify the definition of a MySQL view without dropping it?
- How can we create a MySQL view with a subquery?

Advertisements