Mysql查看数据库对象(SQL命令总结)

2015-03-04 17:07:23 · 作者: · 浏览: 25
Mysql查看 数据库对象(SQL命令总结)
数据的对象包括表,视图,触发器,等等(查看统计信息的必须进入information_schema 数据库)

举例查看表相关的信息,步骤如下
1、使用information_schema 数据库
use information_schema;

2、查询所有数据的大小(MB):
select concat(round(sum(data_length/1024/1024),2),'MB') as data_size from tables; 

3、查看指定数据库(schema)的大小(MB):
select concat(round(sum(data_length/1024/1024),2),'MB') as DB_size from tables where table_schema='ehr';

4、查看指定数据库的指定表(table)的大小

select concat(round(sum(data_length/1024/1024),2),'MB') as table_size from tables where table_schema='ehr' and table_name='ehr_age';

实际生产环境:比逐条执行SQL查看统计信息更厉害的就是现在的UI界面,但是根本的还是SQL语句!