當前位置:成語大全網 - 新華字典 - mysql有常用數據字典查詢方法

mysql有常用數據字典查詢方法

MYSQL沒有這些,MYSQL用SHWO命令查詢數據庫和表、字段、索引等信息:

壹些SHOW語句提供額外的字符集信息。這些語句包括SHOW?CHARACTER?SET、SHOW?COLLATION、SHOW?CREATE?DATABASE、SHOW?CREATE?TABLE和SHOW?COLUMNS。

SHOW?CHARACTER?SET命令顯示全部可用的字符集。它帶有壹個可選的LIKE子句來指示匹配哪些字符集名。例如:

mysql>?SHOW?CHARACTER?SET?LIKE?'latin%';

+---------+-----------------------------+-------------------+--------+

|?Charset?|?Description?|?Default?collation?|?Maxlen?|

+---------+-----------------------------+-------------------+--------+

|?latin1?|?cp1252?West?European|?latin1_swedish_ci?|?1?|

|?latin2?|?ISO?8859-2?Central?European?|?latin2_general_ci?|?1?|

|?latin5?|?ISO?8859-9?Turkish?|?latin5_turkish_ci?|?1?|

|?latin7?|?ISO?8859-13?Baltic?|?latin7_general_ci?|?1?|

+---------+-----------------------------+-------------------+--------+

見13.5.4.1節,“SHOW?CHARACTER?SET語法”。

SHOW?COLLATION語句的輸出包括全部可用的字符集。它帶有壹個可選的LIKE子句來指示匹配哪些?校對規則名。例如:

mysql>?SHOW?COLLATION?LIKE?'latin1%';

+-------------------+---------+----+---------+----------+---------+

|?Collation?|?Charset?|?Id?|?Default?|?Compiled?|?Sortlen?|

+-------------------+---------+----+---------+----------+---------+

|?latin1_german1_ci?|?latin1?|?5?|?|?|0?|

|?latin1_swedish_ci?|?latin1?|?8?|?Yes?|?Yes?|0?|

|?latin1_danish_ci?|?latin1?|?15?|?|?|0?|

|?latin1_german2_ci?|?latin1?|?31?|?|?Yes?|2?|

|?latin1_bin|?latin1?|?47?|?|?Yes?|0?|

|?latin1_general_ci?|?latin1?|?48?|?|?|0?|

|?latin1_general_cs?|?latin1?|?49?|?|?|0?|

|?latin1_spanish_ci?|?latin1?|?94?|?|?|0?|

+-------------------+---------+----+---------+----------+---------+

見13.5.4.2節,“SHOW?COLLATION語法”。

SHOW?CREATE?DATABASE語句顯示創建給定數據庫的CREATE?DATABASE語句。結果包括全部數據庫選項。支持DEFAULT?CHARACTER?SET和COLLATE。全部數據庫選項存儲在命名為db.Opt的文本文件中,該文件能夠在數據庫目錄中找到。

mysql>?SHOW?CREATE?DATABASE?test;

+----------+-----------------------------------------------------------------+

|?Database?|?Create?Database?|

+----------+-----------------------------------------------------------------+

|?test?|?CREATE?DATABASE?`test`?/*!40100?DEFAULT?CHARACTER?SET?latin1?*/?|

+----------+-----------------------------------------------------------------+

見13.5.4.4節,“SHOW?CREATE?DATABASE語法”

SHOW?CREATE?TABLE與SHOW?CREATE?DATABASE相似,但是顯示創建給定數據庫的CREATE?TABLE語句。列定義顯示任何字符集規格,並且表選項包括字符集信息。

見13.5.4.5節,“SHOW?CREATE?TABLE語法”

當以SHOW?FULL?COLUMNS調用時,SHOW?COLUMNS語句顯示表中列的校對規則。具有CHAR、VARCHAR或TEXT數據類型的列有非NULL的?校對規則。數值列和其它非字符類型的列有NULL校對規則。例如:

mysql>?SHOW?FULL?COLUMNS?FROM?person\G

***************************?1.?row?***************************

Field:?id

Type:?smallint(5)?unsigned

Collation:?NULL

Null:?NO

Key:?PRI

Default:?NULL

Extra:?auto_increment

Privileges:?select,insert,update,references

Comment:

***************************?2.?row?***************************

Field:?name

Type:?char(60)

Collation:?latin1_swedish_ci

Null:?NO

Key:

Default:

Extra:

Privileges:?select,insert,update,references

Comment:

字符集不是顯示的部分。(字符集名隱含在校對規則名中。)

見13.5.4.3節,“SHOW?COLUMNS語法”。