Oracle/Mysql 所有表占用空间大小,按照大小倒序

文章目录

  • 一、Mysql
  • 二、Oracle
  • 总结


一、Mysql

SELECT TABLE_NAME,DATA_LENGTH,INDEX_LENGTH,(DATA_LENGTH+INDEX_LENGTH) as  length,
TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,3), 'MB') as total_size 
FROM information_schema.TABLES WHERE TABLE_SCHEMA='Your_Database_Name' order by length desc

二、Oracle

SELECT owner || '.' || segment_name AS table_name,
       bytes / 1024 / 1024 AS size_in_mb
FROM dba_segments
WHERE segment_type = 'TABLE'
      AND owner = 'Your_Database_Name'
ORDER BY size_in_mb DESC;

总结

按照自己节奏和预想来,相信自己。

你可能感兴趣的:(数据库,oracle,mysql,数据库)