ITPub博客

首页 > 数据库 > MySQL > MYSQL常用SQL

MYSQL常用SQL

原创 MySQL 作者:darrenduan 时间:2016-08-13 13:51:18 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/26526320/viewspace-2123432/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: innodb查询锁
请登录后发表评论 登录
全部评论

注册时间:2012-08-22

  • 博文量
    17
  • 访问量
    22511