天天看點

怎樣顯示MYSQL表的資訊

姊妹篇:

http://blog.csdn.net/u010098331/article/details/50699756

在用mysql時(show tables),有時候需要檢視表和字段的相關資訊(表與某字段是否存在等.)

~~而php提供了這樣的相關函數,如:mysql_list_dbs(),mysql_list_fields(),但mysql_list_fields() 函數等已過時,是以要用show...這個sql指令來查尋。

show 指令(‘[..]’裡的可選)

#顯示mysql中所有資料庫的名稱

show databases;

#顯示mysql中的相關表

show tables [ from db_name]

#檢視存儲過程狀态

show procedure status

#顯示表中列名稱

show columns from table_name [ from database_name ] ; 或show columns from database_name.table_name;

#顯示一個使用者的權限,顯示結果類似于grant 指令

show grants for user_name;

#顯示表的索引

show index from table_name

#顯示一些系統特定資源的資訊,例如,正在運作的線程數量

show status [from   db_name]

#顯示系統變量的名稱和值

show [ global] variables

#顯示系統中正在運作的所有程序,也就是目前正在執行的查詢大多數使用者可以檢視他們自己的程序,但是如果他們擁有process權限,就可以檢視所有人的程序,包括密碼

show processlist

#顯示目前使用或者指定的database中的每個表的資訊資訊包括表類型和表的最新更新時間

show table status

#顯示伺服器所支援的不同權限

show privileges

#顯示create database 語句是否能夠建立指定的資料庫

show create database database_name

show create table table_name

#顯示安裝以後可用的存儲引擎和預設引擎

show engies

#顯示innodb存儲引擎的狀态

show innodb status

#顯示bdb存儲引擎的日志

show logs   -----這個已經被遺棄了

#顯示最後一個執行的語句所産生的錯誤、警告和通知

show warnings

#隻顯示最後一個執行語句所産生的錯誤

show errors

#顯示安裝後的可用存儲引擎和預設引擎

show [storage] engines;

============================================================

mysqlshow,該指令隻參顯示資料庫、表、列的資訊

例如:mysqlshow   -uroot   -pxxxx   mysql   #顯示mysql資料庫的資訊

例如:mysqlshow   -uroot   -pxxxx   mysql   user   #顯示mysql資料庫中user表的資訊

例如:mysqlshow   -uroot   -pxxxx   mysql   user   user   #顯示mysql資料庫中user表中的user列的資訊