mysql如何查询数据库容量

数据库   发布日期:2024年04月18日   浏览次数:739

本篇内容介绍了“mysql如何查询数据库容量”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

mysql查询数据库容量的方法:1、打开DOS窗口,然后进入mysql的bin目录下;2、执行“SELECT table_schema AS 'shujuku',table_name AS 'biaoming',table_rows AS 'jilushu',TRUNCATE (data_length / 1024 / 1024, 2) ...”语句即可查看所有数据库各表容量。

MySql查看数据库及表容量并排序查看所有数据库容量

  1. SELECT
  2. table_schema AS '数据库',
  3. sum(table_rows) AS '记录数',
  4. sum(
  5. TRUNCATE (data_length / 1024 / 1024, 2)
  6. ) AS '数据容量(MB)',
  7. sum(
  8. TRUNCATE (index_length / 1024 / 1024, 2)
  9. ) AS '索引容量(MB)'
  10. FROM
  11. information_schema. TABLES
  12. GROUP BY
  13. table_schema
  14. ORDER BY
  15. sum(data_length) DESC,
  16. sum(index_length) DESC;

查看所有数据库各表容量

  1. SELECT
  2. table_schema AS '数据库',
  3. table_name AS '表名',
  4. table_rows AS '记录数',
  5. TRUNCATE (data_length / 1024 / 1024, 2) AS '数据容量(MB)',
  6. TRUNCATE (index_length / 1024 / 1024, 2) AS '索引容量(MB)'
  7. FROM
  8. information_schema. TABLES
  9. ORDER BY
  10. data_length DESC,
  11. index_length DESC;

查看指定数据库容量

  1. SELECT
  2. table_schema AS '数据库',
  3. sum(table_rows) AS '记录数',
  4. sum(
  5. TRUNCATE (data_length / 1024 / 1024, 2)
  6. ) AS '数据容量(MB)',
  7. sum(
  8. TRUNCATE (index_length / 1024 / 1024, 2)
  9. ) AS '索引容量(MB)'
  10. FROM
  11. information_schema.tables where table_schema = 'your_table_name';

查看指定数据库各表容量

  1. SELECT
  2. table_schema AS '数据库',
  3. table_name AS '表名',
  4. table_rows AS '记录数',
  5. TRUNCATE ( data_length / 1024 / 1024, 2 ) AS '数据容量(MB)',
  6. TRUNCATE ( index_length / 1024 / 1024, 2 ) AS '索引容量(MB)'
  7. FROM
  8. information_schema.TABLES
  9. WHERE
  10. table_schema = '指定的库名'
  11. ORDER BY
  12. data_length DESC,
  13. index_length DESC;

以上就是mysql如何查询数据库容量的详细内容,更多关于mysql如何查询数据库容量的资料请关注九品源码其它相关文章!