1.查看表空间的使用情况
SELECT upper(f.tablespace_name) "表空间名",
d.tot_grootte_mb "表空间大小(M)",
d.tot_grootte_mb - f.total_bytes "已使用空间(M)",
to_char(round((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100,
2),
'990.99') "使用比",
f.total_bytes "空闲空间(M)",
f.max_bytes "最大块(M)",
SYSDATE
FROM (SELECT tablespace_name,
round(SUM(bytes) / (1024 * 1024), 2) total_bytes,
round(MAX(bytes) / (1024 * 1024), 2) max_bytes
FROM sys.dba_free_space
GROUP BY tablespace_name) f,
(SELECT dd.tablespace_name,
round(SUM(dd.bytes) / (1024 * 1024), 2) tot_grootte_mb
FROM sys.dba_data_files dd
GROUP BY dd.tablespace_name) d
WHERE d.tablespace_name = f.tablespace_name
ORDER BY 4 DESC;
2. 建立表空间
CREATE TABLESPACE data01 DATAFILE '/oracle/oradata/db/DATA01.dbf' SIZE 500M;
3.删除表空间
DROP TABLESPACE data01 INCLUDING CONTENTS AND DATAFILES;
4. 修改表空间大小
alter database datafile '/path/NADDate05.dbf' resize 100M
5.增加表空间
ALTER TABLESPACE NEWCCS ADD DATAFILE '/u03/oradata/newccs/newccs04.dbf' SIZE 4896M;
6. 查询数据库现在的表空间
select tablespace_name, file_name, sum(bytes)/1024/1024 table_size from dba_data_files group by tablespace_name,file_name;