SHOWFULLCOLUMNSFROMINFO"/> SHOWFULLCOLUMNSFROMINFO">

Home  >  Article  >  Database  >  How can we list all the columns of a MySQL view like the columns of a MySQL table?

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

PHPz
PHPzforward
2023-08-25 23:37:11683browse

我们怎样才能像列出 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;

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)

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!

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