undo数据文件删除-不用创建控制文件

如果这种方式不行,请参考https://blog.csdn.net/m15217321304/article/details/105118977

SQL> select file_name, tablespace_name from dba_data_files;
rows will be truncated


FILE_NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oradata/QXY1/example01.dbf
/u01/app/oradata/QXY1/users01.dbf
/u01/app/oradata/QXY1/sysaux01.dbf
/u01/app/oradata/QXY1/system01.dbf
/u01/app/oradata/QXY1/undotbs2.dbf

SQL> !rm -rf /u01/app/oradata/QXY1/undotbs2.dbf

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@QXY1 backup]$ o

SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 25 23:10:11 2020

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown abort;
ORACLE instance shut down.
SQL> 
SQL> 
SQL> startup force
ORACLE instance started.

Total System Global Area  242208768 bytes
Fixed Size                  2227176 bytes
Variable Size             184550424 bytes
Database Buffers           50331648 bytes
Redo Buffers                5099520 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oradata/QXY1/undotbs2.dbf'


SQL> alter database datafile '/u01/app/oradata/QXY1/undotbs2.dbf' offline drop;

Database altered.

SQL> 
SQL> alter database open;

Database altered.

SQL> 


--//查看udno段的状态
set wrap off
set lin 200
select segment_name,status from dba_rollback_segs where status<>'offline'

SEGMENT_NAME                                                 STATUS
------------------------------------------------------------ --------------------------------
SYSTEM                                                       ONLINE
_SYSSMU30_2529261473$                                        NEEDS RECOVERY
_SYSSMU29_1979358866$                                        NEEDS RECOVERY
_SYSSMU28_546688357$                                         NEEDS RECOVERY
_SYSSMU27_3265773230$                                        NEEDS RECOVERY
_SYSSMU26_3108816978$                                        NEEDS RECOVERY
_SYSSMU25_2524349145$                                        NEEDS RECOVERY
_SYSSMU24_1428422772$                                        NEEDS RECOVERY
_SYSSMU23_4007709708$                                        NEEDS RECOVERY
_SYSSMU22_2369208819$                                        NEEDS RECOVERY
_SYSSMU21_3002512758$                                        NEEDS RECOVERY

--//新建一个回滚表空间
create undo tablespace undotbs1 datafile '/u01/app/oradata/QXY1/undotbs01.dbf' size 50m autoextend off;

SQL> create undo tablespace undotbs1 datafile '/u01/app/oradata/QXY1/undotbs01.dbf' size 50m autoextend off;

Tablespace created.

SQL> 


--//把回滚段设置成人工管理,然后删除损坏的回滚段
alter system set undo_tablespace= 'undotbs1'  scope=spfile; 

SQL> alter system set undo_tablespace= 'undotbs1'  scope=spfile; 

System altered.

SQL> 

SQL> alter system set undo_management='manual'  scope=spfile;

System altered.

SQL> 

--//创建pfile
create pfile='/tmp/pfile.ora'  from spfile;


SQL> create pfile='/tmp/pfile.ora'  from spfile;

File created.

SQL> 

--//关闭数据库
shut  immediate
startup pfile='/tmp/pfile.ora';


--//删除旧的undo表空间

drop tablespace UNDOTBS2 including contents and datafiles;

SQL> drop tablespace UNDOTBS2 including contents and datafiles;
drop tablespace UNDOTBS2 including contents and datafiles
*
ERROR at line 1:
ORA-01548: active rollback segment '_SYSSMU21_3002512758$' found, terminate dropping tablespace


SQL> 

--//把旧的undo段标记为corrupt
*._corrupted_rollback_segments=(_SYSSMU21_3002512758$,_SYSSMU22_2369208819$,_SYSSMU23_4007709708$,_SYSSMU24_1428422772$,_SYSSMU25_2524349145$,_SYSSMU26_3108816978$,_SYSSMU27_3265773230$,_SYSSMU28_546688357$,_SYSSMU29_1979358866$,_SYSSMU30_2529261473$)


--//再次重启数据库
SQL> startup pfile='/tmp/pfile.ora';
ORACLE instance started.

Total System Global Area  242208768 bytes
Fixed Size                  2227176 bytes
Variable Size             184550424 bytes
Database Buffers           50331648 bytes
Redo Buffers                5099520 bytes
Database mounted.
Database opened.
SQL> 

--//删除旧的undo表空间
SQL> drop tablespace UNDOTBS2 including contents and datafiles;

Tablespace dropped.

SQL> 
SQL> 


--//把undo切换为自动管理
alter system set undo_management='auto'  scope=spfile;

--//把/tmp/pfile.ora下面的隐含参数取消重启数据库

SQL>  create spfile from pfile='/tmp/pfile.ora';

File created.

SQL> 
SQL> 
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup 
ORACLE instance started.

Total System Global Area  242208768 bytes
Fixed Size                  2227176 bytes
Variable Size             184550424 bytes
Database Buffers           50331648 bytes
Redo Buffers                5099520 bytes
Database mounted.
Database opened.
SQL> alter system set undo_management='auto'  scope=spfile;

System altered.

SQL> create pfile='/tmp/pfile.ora' from spfile;

File created.

--//删除隐含参数重启

SQL> startup pfile='/tmp/pfile.ora' force;
ORACLE instance started.

Total System Global Area  242208768 bytes
Fixed Size                  2227176 bytes
Variable Size             184550424 bytes
Database Buffers           50331648 bytes
Redo Buffers                5099520 bytes
Database mounted.
Database opened.
SQL> show parameter undo 

NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
undo_management                      string
AUTO
undo_retention                       integer
900
undo_tablespace                      string
undotbs1
SQL> 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章