SHOW [FULL] COLUMNS FROM

SHOW [FULL] COLUMNS FROM 语句用于以表格格式描述表或视图中的列。可选关键字 FULL 用于显示当前用户对该列的权限,以及表定义中的 comment

SHOW [FULL] FIELDS FROMDESC <table>DESCRIBE <table>EXPLAIN <table> 语句都是 SHOW [FULL] COLUMNS FROM 的别名。

语法图

ShowStmt:

ShowStmt

ShowTargetFilterable:

ShowTargetFilterable

OptFull:

OptFull

示例

  1. mysql> create view v1 as select 1;
  2. Query OK, 0 rows affected (0.11 sec)
  3. mysql> show columns from v1;
  4. +-+--++++-+
  5. | Field | Type | Null | Key | Default | Extra |
  6. +-+--++++-+
  7. | 1 | bigint(1) | YES | | NULL | |
  8. +-+--++++-+
  9. 1 row in set (0.00 sec)
  10. mysql> desc v1;
  11. +-+--++++-+
  12. | Field | Type | Null | Key | Default | Extra |
  13. +-+--++++-+
  14. | 1 | bigint(1) | YES | | NULL | |
  15. +-+--++++-+
  16. 1 row in set (0.00 sec)
  17. mysql> describe v1;
  18. +-+--++++-+
  19. | Field | Type | Null | Key | Default | Extra |
  20. +-+--++++-+
  21. | 1 | bigint(1) | YES | | NULL | |
  22. +-+--++++-+
  23. 1 row in set (0.00 sec)
  24. mysql> explain v1;
  25. +-+--++++-+
  26. | Field | Type | Null | Key | Default | Extra |
  27. +-+--++++-+
  28. | 1 | bigint(1) | YES | | NULL | |
  29. +-+--++++-+
  30. 1 row in set (0.00 sec)
  31. mysql> show fields from v1;
  32. +-+--++++-+
  33. | Field | Type | Null | Key | Default | Extra |
  34. +-+--++++-+
  35. | 1 | bigint(1) | YES | | NULL | |
  36. +-+--++++-+
  37. 1 row in set (0.00 sec)
  38. mysql> show full columns from v1;
  39. +-+--+--++++-+++
  40. | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
  41. +-+--+--++++-+++
  42. | 1 | bigint(1) | NULL | YES | | NULL | | select,insert,update,references | |
  43. +-+--+--++++-+++
  44. 1 row in set (0.00 sec)
  45. mysql> show full columns from mysql.user;
  46. +--++-++++-+++
  47. | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
  48. +--++-++++-+++
  49. | Host | char(64) | utf8mb4_bin | NO | PRI | NULL | | select,insert,update,references | |
  50. | User | char(32) | utf8mb4_bin | NO | PRI | NULL | | select,insert,update,references | |
  51. | Password | char(41) | utf8mb4_bin | YES | | NULL | | select,insert,update,references | |
  52. | Select_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  53. | Insert_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  54. | Update_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  55. | Delete_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  56. | Create_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  57. | Drop_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  58. | Process_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  59. | Grant_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  60. | References_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  61. | Alter_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  62. | Show_db_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  63. | Super_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  64. | Create_tmp_table_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  65. | Lock_tables_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  66. | Execute_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  67. | Create_view_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  68. | Show_view_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  69. | Create_routine_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  70. | Alter_routine_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  71. | Index_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  72. | Create_user_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  73. | Event_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  74. | Trigger_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  75. | Create_role_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  76. | Drop_role_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  77. | Account_locked | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  78. +--++-++++-+++
  79. 29 rows in set (0.00 sec)

MySQL 兼容性

SHOW [FULL] COLUMNS FROM 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue

另请参阅