DESCRIBEINFO;+---------+--------- ----+------+---"/> DESCRIBEINFO;+---------+--------- ----+------+---">

Home >Database >Mysql Tutorial >How can we get the structure of a MySQL view just like we get the structure of a MySQL table?

How can we get the structure of a MySQL view just like we get the structure of a MySQL table?

WBOY
WBOYforward
2023-08-27 08:29:161262browse

How can we get the structure of a MySQL view just like we get the structure of a MySQL table?

We know that a view is a virtual table and a combination of tables, so we can use the same query to get the structure of the view, and then use that query to get the structure of the view Structure a table. In other words, we can use the DESCRIBE statement to get the structure of the MySQL view. Its syntax is as follows -

Syntax

DESCRIBE view_name;

Here, view_name is the name of the view whose structure we want to get.

Example

Suppose we want to get the structure of the 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 is shown All fields are defined the same as in the base table.

The above is the detailed content of How can we get the structure of a MySQL view just like we get the structure of a MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete