select TABLE_NAME , num_rows * avg_row_len /1024/1024 AS KJfrom ALL_tables WHERE TABLE_NAME IN (select TABLE_NAME from all_tables where owner='PRODDTA')ORDER BY KJ DESC…
SELECT T.OWNER, T.SEGMENT_NAME, SUM(T.BYTES) / 1024 / 1024 M FROM DBA_SEGMENTS T WHERE T.OWNER = 'user_name' AND T.SEGMENT_NAME = 'table_name' GROUP BY T.OWNER, T.SEGMENT_NAME; 或者 select sum(bytes/1024/1024) M from user_segments where segment_name…
http://www.2cto.com/database/201107/95313.html 一种是分配给一个表的物理空间数量,而不管空间是否被使用.可以这样查询获得字节数:select segment_name, bytes from user_segments where segment_type = 'TABLE'; 或 Select Segment_Name,Sum(bytes)/1024/1024 from User_Extents Group By Segment_Name; 另一种…
TABLE_SCHEMA : 数据库名TABLE_NAME:表名ENGINE:所使用的存储引擎TABLES_ROWS:记录数DATA_LENGTH:数据大小INDEX_LENGTH:索引大小 SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM TABLES WHERE TABLE_SCHEMA='数据库名' AND TABLE_NAME='表名'…
select TABLE_NAME, concat(truncate(data_length/1024/1024,2),'MB') as data_size, concat(truncate(index_length/1024/1024,2),'MB') as index_size from information_schema.tables where TABLE_SCHEMA = '数据库名称' group by TABLE_NAME order by data_length desc;…
通过从视图 user_segments的字段 bytes中找到 select SUM(bytes)/1024/1024 from user_segments where segment_name='EMP'; select segment_name,sum(bytes)/1024/1024 as MB from user_segments group by segment_name order by MB desc;…
由于数据太大了.所以MYSQL需要瘦身,那前提就是需要知道每个表占用的空间大小. 首先打开指定的数据库: use information_schema; 如果想看指定数据库中的数据表,可以用如下语句: ),),'MB') as data from TABLES where table_schema='AAAA' and table_name='BBBB'; 如果想看数据库中每个数据表的,可以用如下语句: ,), 'MB') as data FROM TABLES WHERE TABLE_SCHE…
1.查看表所占空间 SELECT TABLESPACE_NAME,TO_CHAR(SUM(BYTES)/(1024*1024),'999G999D999') CNT_MB FROM DBA_EXTENTS WHERE OWNER='&OWNER' AND SEGMENT_NAME='&TABLE_NAME' AND SEGMENT_TYPE LIKE 'TABLE%' GROUP BY TABLESPACE_NAME;…
Oracle查看表空间及修改数据文件大小 第一步:查看所有表空间及表空间大小: select tablespace_name ,sum(bytes) / 1024 / 1024 as MB from dba_data_files group by tablespace_name; 第二步:查看所有表空间对应的数据文件: select tablespace_name,file_name from dba_data_files; 第三步:修改数据文件大小 alter database datafil…
查询所有数据库占用磁盘空间大小的SQL语句: ,),' MB') as data_size, concat(,),'MB') as index_size from information_schema.tables group by TABLE_SCHEMA order by data_length desc; 查询单个库中所有表磁盘占用大小的SQL语句: ,),' MB') as data_size, concat(,),' MB') as index_size from informatio…
use master go select * from sys.dm_os_buffer_descriptors go --查看数据库在数据缓存(data cache)中占用的空间大小 --由于每个数据页对应动态管理视图(dynamic management view,DMV)中的一行,为128 字节,为1/8个千字节(KB) --1字节(Byte)=8位(Bit) --1千字节(KB)=1024字节(Byte) --1兆(MB)=1024千字节(KB) as 'Cached Size(MB)'…
查询所有数据库占用磁盘空间大小的SQL语句: 复制代码 代码如下:select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_sizefrom information_schema.tablesgroup by TABLE_SCHEMAorder by data…
select t.table_name,t.num_rows from user_tables t ORDER BY NUM_ROWS DESC;//实际行数 analyze table emp compute statistics; select num_rows * avg_row_len from user_tables where table_name = 'TB_SYS_LOG';//某一个表占用的空间 analyze table emp compute statistics; sel…
--1.查看表空间的名称及大小 )), ) ts_size FROM dba_tablespaces t, dba_data_files d WHERE t.tablespace_name = d.tablespace_name GROUP BY t.tablespace_name; --2.查看表空间物理文件的名称及大小 SELECT tablespace_name, file_id, file_name, ), ) total_space FROM dba_data_files ORDER…
最新数据库空间有感觉捉急了,上次,删了些数据空了800+G,撑了一个多月,现在还有400+G,每天10G的增量,多少空间也感觉不够用啊. 不能加硬盘,就只有删数据了.. 删数据,人懒,直接找表行最多,占空间最大的表删 于是就有了下面一段SQL: ||'M' bytes from user_segments group by segment_name) us where ut.TABLE_NAME = us.segment_name order by num_rows desc nulls las…