學習來源: codedata - MySQL 超新手入門(17)查詢 information_schema
DESCRIBE
show
SELECT ROUNTINE_TYPE, ROUNTINE_NAME, CREATED
FROM information_schema.ROUNTINES
SHOW { DATABASES | SCHEMAS } [LIKE '樣板'...]
SHOW TABLES [STATUS] [FROM 資料庫名稱] [LIKE '樣板'... | WHERE 條件 ...]
SHOW [FULL] COLUMNS FROM 表格名稱 [FROM 資料庫名稱]
[LIKE '樣板'... | WHERE 條件 ...]
SHOW INDEX FROM 表格名稱 [FROM 資料庫名稱]
[WHERE 條件...]
SHOW TRIGGERS [FROM 資料庫名稱] [LIKE '樣板' | WHERE 條件...]
SHOW CHARACTER SET [LIKE '樣板'... | WHERE 條件...]
SHOW COLLATION [LIKE '樣板'... | WHERE 條件...]
SHOW [STORAGE] ENGINES
SHOW [GLOBAL | SESSION] STATUS [LIKE '樣板'... | WHERE 條件...]
SHOW [GLOBAL | SESSION] VARIABLES [LIKE '樣板'... | WHERE 條件...]
DESCRIBE
{DESCRIBE | DESC} 表格名稱 [欄位名稱| '樣板'...]
DESC country
DESC country Name
DESC country 'GNP%'
SHOW
MySQL資料庫伺服器提供一個可以在命令提示字元下執行的工具程式「mysqlshow」
mysqlshow -h 資料庫伺服器名稱 -u 帳號 -p密碼
mysqlshow -u root
mysqlshow -u root world
mysqlshow -u root world country
SELECT c.COLUMN_NAME, c.DATA_TYPE, c.COLUMN_COMMENT
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE TABLE_NAME = '資料表'
and Table_SCHEMA = '主機名稱'
and COLUMN_NAME = "欄位名稱"
SELECT column_name, column_comment, column_type, column_default, data_type, is_nullable
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '資料表名稱'
ORDER BY column_name