达梦数据库 如何使用sql语句查询,数据库容量大小和数据库使用量大小

达梦数据库 如何使用sql语句查询,数据库容量大小和数据库使用量大小,第1张

SELECT sum(df.TOTAL_SIZE) - sum(df.FREE_SIZE) as used ,

sum(df.TOTAL_SIZE)as total,

sum(df.FREE_SIZE)as free

FROM "SYS".V$TABLESPACE AS ts, "SYS".V$DATAFILE AS df WHERE ts.ID = df.GROUP_ID

1、查询整个mysql数据库,整个库的大小;单位转换为MB。

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data  from information_schema.TABLES

2、查询mysql数据库,某个库的大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data

from information_schema.TABLES

where table_schema = 'testdb'

3、查看库中某个表的大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data

from information_schema.TABLES

where table_schema = 'testdb'

 and table_name = 'test_a'

4、查看mysql库中,test开头的表,所有存储大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data

from information_schema.TABLES

where table_schema = 'testdb'

 and table_name like 'test%'

1. 查看所有表空间大小 SQL>select tablespace_name,sum(bytes)/1024/1024 from dba_data_files 2 group by tablespace_name2. 已经使用的表空间大小 SQL>select tablespace_name,sum(bytes)/1024/1024 from dba_free_space 2 group by tablespace_name3. 所以使用空间可以这样计算 select a.tablespace_name,total,free,total-free used from ( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files group by tablespace_name) a, ( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space group by tablespace_name) b where a.tablespace_name=b.tablespace_name4. 下面这条语句查看所有segment的大小。 Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name 5. 还有在命令行情况下如何将结果放到一个文件里。 SQL>spool out.txt SQL>select * from v$databaseSQL>spool off


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6802827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-28
下一篇 2023-03-28

发表评论

登录后才能评论

评论列表(0条)

保存