如何在MySQL後設資料庫裡檢視索引,約束,觸發器,儲存過程和事件的相關資訊

chenfeng發表於2017-10-05


-- 檢視主鍵約束
SELECT * FROM information_schema.`TABLE_CONSTRAINTS`;


-- 檢視外來鍵約束
SELECT * FROM information_schema.`REFERENTIAL_CONSTRAINTS`;


-- 檢視錶許可權資訊
SELECT * FROM information_schema.`TABLE_PRIVILEGES`;


-- 檢視所有列DML許可權資訊
SELECT * FROM information_schema.`COLUMN_PRIVILEGES`;


-- 檢視錶索引資訊
SELECT * FROM information_schema.`STATISTICS`;


-- 檢視使用者許可權資訊
SELECT * FROM information_schema.`USER_PRIVILEGES`;
 
-- 檢視觸發器
SELECT * FROM information_schema.`TRIGGERS`;


-- 檢視檢視
SELECT * FROM `information_schema`.`VIEWS`;


-- 檢視儲存過程或儲存函式
SELECT * FROM `information_schema`.`ROUTINES`;


--檢視事件資訊
SELECT * FROM information_schema.events;


備註:檢視Events是否開啟:
mysql> select @@global.event_scheduler;
mysql> show variables like 'event_scheduler';

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2145714/,如需轉載,請註明出處,否則將追究法律責任。

相關文章