转:Oracle:删除表空间
原文: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;
转:Oracle:删除表空间的更多相关文章
- oracle中的sys用户(修改密码)/////Oracle删除表空间的同时删除数据文件 ///// Oracle中如何保证用户只有一个session登录
oracle中的sys用户(修改密码) (2011-07-01 09:18:11) 转载▼ 标签: it 分类: oracle 概念: SYS用户是Oracle中权限最高的用户,而SYSTEM是一个用 ...
- oracle 删除表空间TABLESPACE步骤及注意项
告诉大家,我喜欢通过toad for oralce来实现对oracle数据库的操作. 1.首先通过数据库管理员用户以SYSDBA身份登录.比如使用sys用户去登录 2.查看和记录待删除表空间所在的物理 ...
- oracle 删除表空间及数据文件方法
oracle 11g版本,创建数据库表空间,默认单个数据文件最大为32G,如果数据文件大于32G,可以增加数据文件. --删除空的表空间,但是不包含物理文件 drop tablespace table ...
- 总结Oracle删除表空间遇到的问题
问题1:删除表空间期间遭遇报错 ORA-29857 问题2:删除表空间期间遭遇 ORA-02429 问题3:表空间删除完毕,主机磁盘空间不释放 问题1:删除表空间期间遭遇报错 ORA-29857 删除 ...
- oracle删除表空间和用户
步骤一: 删除tablespace(登录对应用户删除表空间) DROP TABLESPACE tablespace_name INCLUDING CONTENTS AND DATAFILES; 步骤二 ...
- oracle 删除表空间
第一步,删除表空间前如果忘记表空间名称和用户名,可以通过以下命令进行查询. ---查找用户select * from dba_users; --查找工作空间的路径select * from dba_d ...
- Oracle删除表空间报ORA01548
由于undo表空间设置了自动增长,导致替换了好几个undo表空间,就想把原先的undo表空间删掉腾出空间 但删的时候报错 SQL> drop tablespace undotbs1 includ ...
- oracle删除表空间下所有的表
SELECT 'DROP TABLE ' || TABLE_NAME || ' CASCADE CONSTRAINTS' V_NAME FROM DBA_TABLES WHERE TABLESPACE ...
- Oracle 创建/删除 表空间、用户、授权
首先以DBA连接到数据库:sqlplus / as sysdba; --创建表空间 create tablespace test_tablespace datafile 'D:\developer\o ...
随机推荐
- net3:文件上传与图片显示以及HiddenField隐藏字段值的使用
原文发布时间为:2008-07-29 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...
- css解析规则
1.因为css对空格不敏感,因此在每个样式后都要加一个分号,不然会把写在后面的样式当成一个整体来解析,直到遇到分号为止. 2.当遇见不认识的属性或值时,将忽略这个属性,继续解析后面的属性. 3.对于复 ...
- leetcode 318. Maximum Product of Word Lengths
传送门 318. Maximum Product of Word Lengths My Submissions QuestionEditorial Solution Total Accepted: 1 ...
- python(3)- 常用快捷键及基础命令
- Google解决跨域
1.添加 --disable-web-security --user-data-dir=D:\tmp 2.在D的根目录新建tmp文件夹
- codevs——2370 小机房的树
2370 小机房的树 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description 小机房有棵焕狗种的树,树上有N个 ...
- codevs——1958 刺激
1958 刺激 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description saffah的一个朋友S酷爱滑雪,并且追求刺 ...
- Codeforces 959 E Mahmoud and Ehab and the xor-MST
Discription Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him ...
- Java日志框架-Spring中使用Logback(Spring/Spring MVC)
继上一篇文章http://www.cnblogs.com/EasonJim/p/7800880.html中所集成的是基于Java的普通项目,如果要在Spring和Spring MVC上集成,需要做如下 ...
- 使用JavaScript进行进制转换将字符串转换为十进制
JS 是一个很神奇的语言,内制的的很多函数可以帮我们进行数(进)制转换: JS中可以直接使用16进制: var a = 将任意进制字符串转换为十进制,如二进制,八进制,十六进制, 第二数数不写即为最常 ...