# How can we get the structure of a MySQL view as we can get the structure of a MySQL table?

MySQLMySQLi Database

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.

Published on 22-Feb-2018 14:59:55