UNDO_RETENTION
The parameter is used to specify the minimum time (in seconds) for Oracle database to retain undo (UNDO) data. In some scenarios, you may need to adjust this parameter to meet the business's need for the revocation of data retention time. The following is a detailed introduction to how to adjust this parameter:
1. Check the current UNDO_RETENTTION parameter value
Before adjusting the parameters, you can check the current oneUNDO_RETENTION
Setting value. You can use the following SQL statements to view:
SHOW PARAMETER undo_retention;
or
SELECT name, value FROM v$parameter WHERE name = 'undo_retention';
2. Dynamic adjustment of UNDO_RETENTENT parameter
If you want to adjust without restarting the databaseUNDO_RETENTION
Parameters, can be usedALTER SYSTEM
Sentence. The parameters adjusted in this way are still valid after the database instance is restarted because it will modify the initialization parameter file.
-- For example UNDO_RETENTION Set as 3600 Second(Right now 1 Hour) ALTER SYSTEM SET undo_retention = 3600 SCOPE = BOTH;
Code explanation:
-
ALTER SYSTEM SET
Used to modify system-level parameters. -
undo_retention = 3600
Indicates that it willUNDO_RETENTION
The value of the parameter is set to 3600 seconds. -
SCOPE = BOTH
It means that the parameter value and initialization parameter file of the current instance are modified at the same time, so that the settings will still take effect after the database is restarted.
3. Static adjustment UNDO_RETENTTION parameter
Static adjustment requires modification of the initialization parameter file (such asor
), and restart the database to make the settings take effect. This method is suitable for some special cases, such as when dynamic adjustment parameters are invalid.
3.1 Modify the file
If you are usingFile, you can edit the file directly, add or modify it
undo_retention
Parameter line:
undo_retention = 3600
After the modification is completed, save the file and restart the database:
-- by Oracle User ID login,Close the database sqlplus / as sysdba SHUTDOWN IMMEDIATE; -- Start the database STARTUP;
3.2 Modify the file
If you are usingFiles can be used
ALTER SYSTEM
The statement writes the parameter value tospfile
, and then restart the database:
ALTER SYSTEM SET undo_retention = 3600 SCOPE = SPFILE;
Then restart the database to make the modification take effect:
-- by Oracle User ID login,Close the database sqlplus / as sysdba SHUTDOWN IMMEDIATE; -- Start the database STARTUP;
4. Things to note
- Parameter influence: increase
UNDO_RETENTION
The value increases the usage of the undo tablespace, so you need to make sure that the undo tablespace has enough space to store the undo data for a longer period of time. - Test verification: Before adjusting this parameter in a production environment, it is recommended to test it in a test environment first, and observe the impact of the adjustment on database performance and undo tablespace usage.
This is the article about how to adjust the UNDO_RETENTION parameters of Oracle database. For more related content on Oracle UNDO_RETENTION parameters, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!