Oracle表空间查询、更新SQL语句

阅读更多

1、查看表空间使用情况

SELECT a.tablespace_name "表空间名称",
total / (1024 * 1024) "表空间大小(M)",
free / (1024 * 1024) "表空间剩余大小(M)",
(total - free) / (1024 * 1024 ) "表空间使用大小(M)",
total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
round((total - free) / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name

2、表空间的位置

select t1.name,t2.name
         from v$tablespace t1,v$datafile t2
         where t1.ts# = t2.ts#;

3、查看表空间是否自动增长

SELECT FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE FROM dba_data_files;

4、增加表空间的文件(其中YKT_SPACE是表空间名称,文件大小5G,一次增加1G)

alter tablespace YKT_SPACE add datafile 'G:\APP\YKT_CENTER\YKT_SPACE02.DBF' size 5120m reuse autoextend on next 1024m;

你可能感兴趣的:(Oracle表空间查询、更新SQL语句)