MySQL常用SQL

darrenduan發表於2016-08-13
A quick way to list your FKs (Foreign Key references) using the KEY_COLUMN_USAGE view:

SELECT CONCAT( table_name, '.',
column_name, ' -> ',
referenced_table_name, '.',
referenced_column_name ) AS list_of_fks
FROM information_schema.KEY_COLUMN_USAGE
WHERE REFERENCED_TABLE_SCHEMA = (your schema name here)
AND REFERENCED_TABLE_NAME is not null
ORDER BY TABLE_NAME, COLUMN_NAME;


統計庫大小
SELECT concat( table_schema, '.', table_name ) table_name, 
concat( round( data_length / ( 1024 *1024 ) , 2 ) , 'M' ) data_length, 
concat( round( index_length / ( 1024 *1024 ) , 2 ) , 'M' ) index_length, 
concat( round( round( data_length + index_length ) / ( 1024 *1024 ) , 2 ) , 'M' ) total_size
FROM information_schema.TABLES
ORDER BY data_length DESC;

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

相關文章