Home > Database > Mysql Tutorial > body text

How can we list all the columns of a MySQL view like the columns of a MySQL table?

PHPz
Release: 2023-08-25 23:37:11
forward
707 people have browsed it

我们怎样才能像列出 MySQL 表的列一样列出 MySQL 视图的所有列呢?

We know that a view is a virtual table and a combination of tables, so we can use the same query to list all columns of a MySQL view, just like we can Dequeuing is the same as for MySQL tables. In other words, we can use the SHOW FULL COLUMNS statement to get the structure of the MySQL view. Its syntax is as follows -

Syntax

SHOW FULL COLUMNS FROM View_name;
Copy after login

Here view_name is the name of the view from which we want to get the column list.

Example

Suppose we want to get the column list of the view named "Info" then it can be done with the help of the following query -

mysql> SHOW FULL COLUMNS FROM INFO\G
*************************** 1. row ***************************
     Field: ID
      Type: int(11)
 Collation: NULL
      Null: YES
       Key:
   Default: NULL
     Extra:
Privileges: select,insert,update,references
   Comment:
*************************** 2. row ***************************
     Field: NAME
      Type: varchar(20)
 Collation: latin1_swedish_ci
      Null: YES
       Key:
   Default: NULL
     Extra:
Privileges: select,insert,update,references
   Comment:
*************************** 3. row ***************************
     Field: SUBJECT
      Type: varchar(20)
 Collation: latin1_swedish_ci
      Null: YES
       Key:
   Default: NULL
     Extra:
Privileges: select,insert,update,references
   Comment:
*************************** 4. row ***************************
     Field: ADDRESS
      Type: varchar(20)
 Collation: latin1_swedish_ci
      Null: YES
       Key:
   Default: NULL
     Extra:
Privileges: select,insert,update,references
   Comment:
4 rows in set (0.00 sec)
Copy after login

The above is the detailed content of How can we list all the columns of a MySQL view like the columns 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!