2011-10-20 67 views
13

我想查看個別字段的評論。通常我期望從「描述」參數。如何從mysql客戶端查看錶註釋?

mysql> describe metrics; 
+-------+---------------------+------+-----+---------+----------------+ 
| Field | Type    | Null | Key | Default | Extra   | 
+-------+---------------------+------+-----+---------+----------------+ 
| id | int(10) unsigned | NO | PRI | NULL | auto_increment | 
| ty | int(10) unsigned | NO |  | NULL |    | 
| t  | bigint(20) unsigned | NO |  | NULL |    | 
| s  | int(10) unsigned | NO |  | 60000 |    | 
| e  | int(10) unsigned | NO |  | NULL |    | 
| c  | int(10) unsigned | NO |  | NULL |    | 
+-------+---------------------+------+-----+---------+----------------+ 

回答

12

該查詢會給你比describe聲明更多的信息:

SELECT * 
FROM information_schema.columns 
WHERE table_name = 'metrics' 
AND table_schema = '...' -- Optionally, filter the schema as well, to avoid conflicts 
+0

你需要搜索DB ** ** TABLE_SCHEMA,一個例子:'在表格名= 'MY_TABLE' 和TABLE_SCHEMA =「my_db'' – KingRider

+0

@KingRider:你說得對,謝謝。那會更完整。我已經更新了答案。 –

49
show full columns from <table_name> 

這是輸出:

| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment 

我希望這是給你的

有用
+0

這應該被標記爲正確的答案。 – zgc7009

3

長途·您可以使用:

show create table <tablename>