- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements