mysql获取表名和注释

发布时间: 2023-11-21 13:13 阅读: 文章来源:1MUMB4925PS
查各表数据量 -- 查各表数据量SELECTtable_schema AS ‘数据库名‘,table_name AS ‘表名‘,TABLE_COMMENT AS ‘表注释‘,CREATE_TIME AS ‘创建时间‘,UPDATE_TIME AS ‘最新更新时间‘,table_rows AS ‘数据量‘ FROMinformation_schema.TABLES WHEREtable_schema NOT LIKE ‘information_schema‘ AND table_name NOT LIKE ‘%bak%‘ AND table_name NOT LIKE ‘%performance_schema%‘;

查询各表数据量

查看所有数据库各表容量大小-- 查看所有数据库各表容量大小selecttable_schema as ‘数据库‘,table_name as ‘表名‘,table_rows as ‘记录数‘,truncate(data_length/1024/1024, 2) as ‘数据容量(MB)‘,truncate(index_length/1024/1024, 2) as ‘索引容量(MB)‘from information_schema.tablesorder by data_length desc, index_length desc;

查看所有数据库各表容量大小

查看所有数据库各容量大小-- 查看所有数据库各容量大小selecttable_schema as ‘数据库‘,sum(table_rows) as ‘记录数‘,sum(truncate(data_length/1024/1024, 2)) as ‘数据容量(MB)‘,sum(truncate(index_length/1024/1024, 2)) as ‘索引容量(MB)‘from information_schema.tablesgroup by table_schemaorder by sum(data_length) desc, sum(index_length) desc;

查看所有数据库各容量大小

统计每个库大小-- 统计每个库大小SELECTtable_schema,SUM(AVG_ROW_LENGTH*TABLE_ROWS+INDEX_LENGTH)/1024/1024 AS total_mbFROM information_schema.TABLES group by table_schema;

统计每个库大小

•••展开全文