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
Release: 2023-08-27 08:29:16
forward
1233 people have browsed it

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;
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template