Shrink undo logs tips

Shrink undo logs tips

Question: 

I have One undo Table space with 4 undo datafiles in my production database Oracle 12c and standby database.
Each data file size is 30 gig but uses only 1 gig.
Can I resize (shrink) all undo data files without any downtime.
Answer: Yes, you can shrink UNDO
while online, but it is a bit tricky:

Please
read: Undo tablespace sizing It's tricky because you cannot shrink the current undo log, you can only shrink those undo files that are not currently in-use. You can shrink the datafile of the UNDO tablespace on the primary database to 5G by using the following command: alter database datafile '/ou1/app/oracley/undo_ts01.dbf' resize 2G; You must Supply the correct file name in the above command. | For ASM, you must specify the correct ASM filename. The undo datafile on the standby If you get this error: ORA-03297: file contains used data beyond requested RESIZE value This ORA-03297 error says that only space can be released if it is at the end of the datafile. The undo segments may be scattered all over the UNDO datafile. In this case you have to do the following on the database: -- Create new undo tablespace with smaller size. SQL> create undo tablespace UNDO_RBS1 datafile 'undorbs1.dbf' size 2G; -- Set the new tablespace as an undo_tablespace SQL> alter system set undo_tablespace=undo_rbs1; -- Drop the old tablespace. SQL> drop tablespace undo_rbs0 including contents. -- Create new undo tablespace with smaller size. SQL> create undo tablespace UNDO_RBS1 datafile 'undorbs1.dbf' size 2G; -- Set new tablespace as undo_tablespace SQL> alter system set undo_tablespace=undo_rbs1; -- Drop the old tablespace. SQL> drop tablespace undo_rbs0 including contents. Dropping the old tablespace may give the ORA-30013 : undo tablespace '%s' is currently in use.
This error indicates you must wait for the undo tablespace to become unavailable.
In other words, you must wait for existing transaction to commit or rollback.

猜你喜欢

转载自www.cnblogs.com/chendian0/p/10937363.html