首页  >  文章  >  数据库  >  我们怎样才能像列出 MySQL 表的列一样列出 MySQL 视图的所有列呢?

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

PHPz
PHPz转载
2023-08-25 23:37:11680浏览

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

我们知道视图是一种虚拟表,也是表的组合,因此我们可以使用相同的查询来列出 MySQL 视图的所有列,就像我们可以列出列一样MySQL 表的。换句话说,我们可以使用SHOW FULL COLUMNS语句来获取MySQL视图的结构。其语法如下 -

语法

SHOW FULL COLUMNS FROM View_name;

这里 view_name 是我们想要从中获取列列表的视图的名称。

示例

假设我们想要获取名为“Info”的视图的列列表,然后可以在以下查询的帮助下完成 -

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)

以上是我们怎样才能像列出 MySQL 表的列一样列出 MySQL 视图的所有列呢?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除