在ORACLE数据库中彻底删除数据文件

归档模式下:alter database drop datafile 'xxx/xxx.dbf';
非归档模式下 :alter database drop datafile 'xxx/xxx.dbf' offline;
 
以上命令只是将该数据文件OFFLINE,而不是在数据库中删除数据文件。该数据文件的信息在控制文件种仍存在。
查询v$datafile,仍显示该文件。
 
要彻底在数据库中删除该数据文件,只有1种方法:删除该数据文件的表空间:drop tablespace tp_xx including contents and datafiles;
--------------------------------------------------------------------
数据文件信息在两个地方保存:控制文件和数据字典,可以在NOMOUNT下重建控制文件(在创建控制文件的脚本中删除该数据文件),但这样无法删除数据字典里的信息,启动数据库后,在v$datafile里仍有这个文件,但名称变成了mising####,文件位置变成了:D:/ORACLE/ORA92/DATABASE/,文件大小变成了0.
 
官方文档里这样说:
DATAFILE Clauses
The DATAFILE clauses affect your database files as follows:

ONLINE
Specify ONLINE to bring the datafile online.

OFFLINE
Specify OFFLINE to take the datafile offline. If the database is open, you must perform media recovery on the datafile before bringing it back online, because a checkpoint is not performed on the datafile before it is taken offline.

DROP
If the database is in NOARCHIVELOG mode, you must specify the DROP clause to take a datafile offline. However, the DROP clause does not remove the datafile from the database. To do that, you must drop the tablespace in which the datafile resides. Until you do so, the datafile remains in the data dictionary with the status RECOVER or OFFLINE.

If the database is in ARCHIVELOG mode, Oracle ignores the DROP keyword.
--------------------------------------------------------------------
 
备份控制文件到trace中:alter database backup controlfile to trace [ as 'c:/ctl.bak' ];
 
---------------
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值