您好,登錄后才能下訂單哦!
下面講講關于查看MySQL中對象的操作方法,文字的奧妙在于貼近主題相關。所以,閑話就不談了,我們直接看下文吧,相信看完查看MySQL中對象的操作方法這篇文章你一定會有所受益。
表:
select TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE from information_schema.tables where TABLE_SCHEMA not in ('performance_schema','information_schema','mysql');
視圖:
select TABLE_SCHEMA,TABLE_NAME from information_schema.tables where table_type='view';
索引:
SELECT TABLE_SCHEMA,TABLE_NAME,INDEX_NAME,INDEX_TYPE FROM INFORMATION_SCHEMA.STATISTICS ;
存儲過程:
select db,name from mysql.proc ;
函數:
select * from mysql.func
事件:
select db,name from mysql.event;
觸發器:
select TRIGGER_SCHEMA,TRIGGER_NAME from information_schema.`TRIGGERS`;
約束
select TABLE_SCHEMA,TABLE_NAME,CONSTRAINT_NAME,CONSTRAINT_TYPE from information_schema.`TABLE_CONSTRAINTS`;
外鍵:
select CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME, REFERENCED_TABLE_NAME from `information_schema`.REFERENTIAL_CONSTRAINTS ;
判斷所有的表是否有主鍵:
SELECT
TABLE_SCHEMA,table_name
FROM
information_schema.TABLES
WHERE
table_schema not in ('information_schema','performance_schema','sys','mysql') AND
TABLE_NAME NOT IN (
SELECT
table_name
FROM
information_schema.table_constraints t
JOIN information_schema.key_column_usage k USING (
constraint_name,
table_schema,
table_name
)
WHERE
t.constraint_type = 'PRIMARY KEY'
AND t.table_schema not in ('information_schema','performance_schema','sys','mysql')
);
統計MySQL數據庫的數據量
SELECT TABLE_SCHEMA,TABLE_NAME,ENGINE,TABLE_ROWS,AVG_ROW_LENGTH,concat(ROUND(DATA_LENGTH/1024/1024/1024,2),'G') "DATA_LENGTH" ,concat(ROUND(INDEX_LENGTH/1024/1024/1024,2),'G') "INDEX_LENGTH",concat(ROUND((INDEX_LENGTH/1024/1024/1024)+(DATA_LENGTH/1024/1024/1024),2),'G') "Total",TABLE_COLLATION,CREATE_TIME FROM
INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'xxx' ORDER BY TABLE_ROWS DESC;
對于以上查看MySQL中對象的操作方法相關內容,大家還有什么不明白的地方嗎?或者想要了解更多相關,可以繼續關注我們的行業資訊板塊。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。