SHOW [FULL] COLUMNS FROM

The statement SHOW [FULL] COLUMNS FROM <table_name> describes the columns of a table or view in a useful tabular format. The optional keyword FULL displays the privileges the current user has to that column, and the comment from the table definition.

The statements SHOW [FULL] FIELDS FROM <table_name>, DESC <table_name>, DESCRIBE <table_name>, and EXPLAIN <table_name> are aliases of this statement.

SHOW COLUMNS FROM - 图1

Note

DESC TABLE <table_name>, DESCRIBE TABLE <table_name>, and EXPLAIN TABLE <table_name> are not equivalent to the above statements. They are aliases of DESC SELECT * FROM .

Synopsis

ShowColumnsFromStmt

SHOW COLUMNS FROM - 图2

TableName

SHOW COLUMNS FROM - 图3

ShowLikeOrWhere

SHOW COLUMNS FROM - 图4

  1. ShowColumnsFromStmt ::=
  2. "SHOW" "FULL"? ("COLUMNS" | "FIELDS") ("FROM" | "IN") TableName ( ("FROM" | "IN") SchemaName)? ShowLikeOrWhere?
  3. TableName ::=
  4. (Identifier ".")? Identifier
  5. ShowLikeOrWhere ::=
  6. "LIKE" SimpleExpr
  7. | "WHERE" Expression

Examples

  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(255) | utf8mb4_bin | NO | PRI | NULL | | select,insert,update,references | |
  50. | User | char(32) | utf8mb4_bin | NO | PRI | NULL | | select,insert,update,references | |
  51. | authentication_string | text | utf8mb4_bin | YES | | NULL | | select,insert,update,references | |
  52. | plugin | char(64) | utf8mb4_bin | YES | | NULL | | select,insert,update,references | |
  53. | Select_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  54. | Insert_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  55. | Update_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  56. | Delete_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  57. | Create_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  58. | Drop_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  59. | Process_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  60. | Grant_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  61. | References_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  62. | Alter_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  63. | Show_db_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  64. | Super_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  65. | Create_tmp_table_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  66. | Lock_tables_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  67. | Execute_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  68. | Create_view_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  69. | Show_view_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  70. | Create_routine_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  71. | Alter_routine_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  72. | Index_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  73. | Create_user_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  74. | Event_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  75. | Repl_slave_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  76. | Repl_client_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  77. | Trigger_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  78. | Create_role_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  79. | Drop_role_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  80. | Account_locked | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  81. | Shutdown_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  82. | Reload_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  83. | FILE_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  84. | Config_priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  85. | Create_Tablespace_Priv | enum('N','Y') | utf8mb4_bin | NO | | N | | select,insert,update,references | |
  86. | User_attributes | json | NULL | YES | | NULL | | select,insert,update,references | |
  87. +------------------------+---------------+-------------+------+------+---------+-------+---------------------------------+---------+
  88. 38 rows in set (0.00 sec)

MySQL compatibility

The SHOW [FULL] COLUMNS FROM statement in TiDB is fully compatible with MySQL. If you find any compatibility differences, report a bug.

See also