oracle 删除表、表空间、用户时,如何释放磁盘空间
(2012-06-13 10:41:43)
标签:
it |
执行drop table xx 语句
举例如下:
===============================================================================
SQL> select * from test1;
A B C
-- -- ----------
11 5
11 10
2 rows selected
SQL> create table test2 as select * from
test1;
Table created
SQL> select * from test2;
A B C
-- -- ----------
11 5
11 10
2 rows selected
SQL> drop table test2;
Table dropped
SQL> select object_name, original_name, operation,
type from user_recyclebin;
OBJECT_NAME ORIGINAL_NAME OPERATION TYPE
------------------------------ --------------------------------
--------- -------------------------
BIN$vQwemDg4R9mK9fYJNdYzvg==$0 TEST2 DROP TABLE
SQL> flashback table test2 to before drop rename to
test3;--【to test3】将表重命名
Done
SQL> select * from test3;
A B C
-- -- ----------
11 5
11 10
2 rows selected
SQL> select * from test2
ORA-00942: 表或视图不存在
--彻底删除表
SQL> drop table test3 purge;
Table dropped
二、清除表中的数据
truncate操作 同没有where条件的delete操作十分相似,只是把表里的信息全部删除,但是表依然存在。
例如:truncate table
Truncate不支持回滚,并且不能truncate一个带有外键的表,如果要删除首先要取消外键,然后再删除。
truncate table 后,有可能表空间仍没有释放,可以使用如下语句:
alter table 表名称
deallocate
注意如果不加KEEP 0的话,表空间是不会释放的。
例如:
alter table F_MINUTE_TD_NET_FHO_B7
deallocate
或者:
TRUNCATE TABLE (schema)table_name DROP(REUSE) STORAGE才能释放表空间。
例如: truncate table
三、查询分区表存在哪些分区:
查询分区表的情况,可以在USER_TAB_PARTITIONS中查询。例如:
四、清除分区表占用的空间:
alter table 表名称
五、查询表空间信息
可以使用如下语句,查询存储空间情况:
Select Tablespace_Name, Sum(bytes)/1024/1024 From Dba_Segments
group By Tablespace_Name
六、查询用户下的表

加载中…