mysql查询数据库容量

更新于 2023-05-06 15:16 54
专栏: MySQL 标签: mysql

  1. SELECT
  2. TABLE_SCHEMA AS "数据库",
  3. sum( table_rows ) AS "记录数",
  4. concat( TRUNCATE ( sum( data_length ) / 1024 / 1024, 2 ), ' MB' ) / 1024 AS "数据容量(GB)",
  5. concat( TRUNCATE ( sum( index_length ) / 1024 / 1024, 2 ), 'MB' ) / 1024 AS "索引容量(GB)"
  6. FROM
  7. information_schema.TABLES
  8. WHERE
  9. table_schema = 'water_affairs';