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> 

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