原文:http://space.itpub.net/40239/viewspace-365948

OMF和非OMF管理的数据文件在DROP TABLESPACE时是否会自动删除,做了测试:

SQL> alter system set db_create_file_dest='/oradata/data/standby' scope=both;

System altered.

SQL> show parameter db_create

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      /oradata/data/standby
db_create_online_log_dest_1          string
db_create_online_log_dest_2          string
db_create_online_log_dest_3          string
db_create_online_log_dest_4          string
db_create_online_log_dest_5          string

SQL> create tablespace t3 datafile size 10m;

Tablespace created.

SQL> select * from v$tablespace;

TS# NAME                           INC
---------- ------------------------------ ---
         0 SYSTEM                         YES
         1 UNDOTBS1                       YES
         2 TEMP                           YES
         3 INDX                           YES
         4 USR                            YES
         5 KONG                           YES
         6 TEST                           YES
         9 T1                             YES
         8 LOGMNRTS                       YES
        10 T2                             YES
        11 T3                             YES

11 rows selected.

SQL> select name from v$datafile  where ts# = 11;

NAME
--------------------------------------------------------------------------------
/oradata/data/standby/o1_mf_t3_464smo7s_.dbf

SQL> create table t100 (id int) tablespace t3;

Table created.

SQL> drop tablespace t3;
drop tablespace t3
*
ERROR at line 1:
ORA-01549: tablespace not empty, use INCLUDING CONTENTS option

SQL> drop tablespace t3 including contents ;

Tablespace dropped.

SQL> !ls -l /oradata/data/standby/o1_mf_t3_464smo7s_.dbf
ls: 0653-341 The file /oradata/data/standby/o1_mf_t3_464smo7s_.dbf does not exist.

看到在DROP TABLESPACE时,就算没有加上 and datafiles是选项,ORACLE也会自动删除数据文件;

SQL> create tablespace t3 datafile '/oradata/data/standby/data/t3.dbf' size 10m;

Tablespace created.

SQL> create table t100 (a int) tablespace t3;

Table created.

SQL> drop tablespace t3 ;
drop tablespace t3
*
ERROR at line 1:
ORA-01549: tablespace not empty, use INCLUDING CONTENTS option

SQL> drop tablespace t3  including contents;

Tablespace dropped.

SQL> !ls -l /oradata/data/standby/data/t3.dbf
-rw-r-----   1 oracle   dba        10493952 Jun 25 23:42 /oradata/data/standby/data/t3.dbf

没有加上and datafiles参数时,oracle不会自动删除datafiles。

SQL> create tablespace t3 datafile '/oradata/data/standby/data/t4.dbf' size 10m;

Tablespace created.

SQL> create table t100 (a int) tablespace t3;

Table created.

SQL> drop tablespace t3  including contents and datafiles;

Tablespace dropped.

SQL> !ls -l /oradata/data/standby/data/t4.dbf
ls: 0653-341 The file /oradata/data/standby/data/t4.dbf does not exist.

加上and datafiles参数时,oracle会自动删除datafiles。

SQL> alter system set db_create_file_dest='' scope=both;

System altered.

SQL> create tablespace t3 datafile '/oradata/data/standby/data/t4.dbf' size 10m;

Tablespace created.

SQL> create table t100 (a int) tablespace t3;

Table created.

SQL> drop tablespace t3  including contents and datafiles;

Tablespace dropped.

SQL> !ls -l /oradata/data/standby/data/t4.dbf
ls: 0653-341 The file /oradata/data/standby/data/t4.dbf does not exist.

SQL>

===============================================

SQL code:

--删除空的表空间,但是不包含物理文件
drop tablespace tablespace_name;

--删除非空表空间,但是不包含物理文件
drop tablespace tablespace_name including contents;

--删除空表空间,包含物理文件
drop tablespace tablespace_name including datafiles;

--删除非空表空间,包含物理文件
drop tablespace tablespace_name including contents and datafiles;

--如果其他表空间中的表有外键等约束关联到了本表空间中的表的字段,就要加上CASCADE CONSTRAINTS
drop tablespace tablespace_name including contents and datafiles CASCADE CONSTRAINTS;

最新文章

  1. tab切换效果
  2. [转]mysql binlog in realtime
  3. MAX(A,B)
  4. Growing转化的每一步(笔记整理)
  5. 根据域名获取IP地址,并探测是否可达
  6. 最全的PHP开发Android应用程序
  7. FZU 2216 The Longest Straight 二分
  8. Qt串口通信
  9. 24_Core Data Demo
  10. Swift - 几种使用数组的数据存储模型
  11. Redis 的几种数据结构&五种数据类型对象
  12. Hive分区表动态添加字段
  13. js中如何向json数组添加元素
  14. 根据http获取的String数据,String数据中含有其他的字符时
  15. js实现右击
  16. Linux find查找指定文件 按照名称 然后cp拷贝到指定目录且指定文件名
  17. 布局:上下两个div高度固定,中间自适应
  18. 对一个前端使用AngularJS后端使用ASP.NET Web API项目的理解(1)
  19. WIN10系统如何取消右下角的通知菜单,通知图标
  20. php分享十八七:mysql基础

热门文章

  1. StoryBoard中,TableView位置总是在顶部出现空白的解决
  2. ORACLE RMAN增量备份经典理解
  3. What should do in Production
  4. Log4J使用详情
  5. kafka exactly-once
  6. scapy在wlan中的应用
  7. 转:linux下共享库的注意点之-fpic
  8. [cocos2d-x]怎样降低cocos2d-x游戏的耗电量?
  9. binary-tree-preorder-traversal——前序遍历
  10. k进制正整数的对k-1取余与按位取余