#查询MySQL服务中数据库表数据量 SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES GROUP BY table_schema; #查询指定数据库表数量 SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES WHERE table_schema = 'szdb'
#查询一个表中有多少字段 SELECT COUNT(*) FROM information_schema. COLUMNS WHERE table_schema = 'szdb' AND table_name = 'SystemLog'; #查询一个数据库中有多少字段 SELECT COUNT(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'szdb'; #查询数据库中所以表、字段、字段类型、注释等信息 SELECT TABLE_NAME, column_name, DATA_TYPE, column_comment FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'szdb' ;
select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024/1024,2),' GB') as data_size, concat(truncate(sum(index_length)/1024/1024/1024,2),'GB') as index_size from information_schema.tables group by TABLE_SCHEMA order by data_length desc;