转: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 ...
随机推荐
- *LOJ#2322. 「清华集训 2017」Hello world!
$n \leq 50000$的树,有点权$\leq 1e13$,$q \leq 400000$次操作,有两种操作:从$s$跳到$t$每次$k$步,不到$k$步直接跳到$t$,每次把经过的点取根号:同样 ...
- python学习之-requests模块基础
安装版本:2.18 模块导入:import requests l 发送请求 发送GET请求: 获取GITHUB的公共时间线 r = requests.get(url='https://api.git ...
- Container With Most Water 双指针法
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). ...
- 51 NOD 1406 and query
我们知道一个数S会对所有它的子集S'产生1的贡献,但是我们直接枚举子集是 3^(log2 1000000)的,会炸掉:如果直接把每个有1的位变成0往下推也会凉掉,因为这样会有很多重复的. 但是我们发现 ...
- dropwizard问题记录1:如何进行mvn package打包,如何在项目目录下运行
dropwizard的helloworld入门教程,跟着教程一步步写很容易,但是最后打包时暴露了自己底子太差的缺陷 mvn package操作 之前工作中完全没有接触过这种打包方式,都是直接打war包 ...
- 微软CIO如何与业务部门打交道?
微软公司副总裁兼CIO Tony Scott是一个非常智慧的人,他拒绝和CEO讨论IT成本的问题,认为IT不应该谈论成本,而是应该谈论IT提供服务的价值.在满足业务部门需求.为业务部门提供适当的IT支 ...
- 【Mybatis】 Mybatis在xml文件中处理大于号小于号的方法【问题】
处理大于小于号的方法: https://www.cnblogs.com/winner-0715/p/6132755.html 第一种方法:用转义字符把">"和"&l ...
- 自己动手实现浏览器,21天自制chromium:起手篇
转:https://zhuanlan.zhihu.com/p/29101613?utm_medium=social&utm_source=qq 大家好,我又来了.这篇是21天自制原子弹的姐妹篇 ...
- python异常捕获异常堆栈输出
python异常捕获异常堆栈输出 学习了:https://blog.csdn.net/chris_grass/article/details/77927902 import traceback def ...
- Android6.0权限管理以及使用权限该注意的地方
Android 6.0 Marshmallow首次增加了执行时权限管理,这对用户来说,能够更好的了解.控 制 app 涉及到的权限.然而对开发人员来说却是一件比較蛋疼的事情.须要兼容适配,并保证程序功 ...