databasePurging Unused Data from Oracle Database(purgeoracle)

Nowadays, databasepurging unused data in Oracle database has become the most important database maintenance task, due to the increasing large database size and growing demands of database performance. Database purging is used to clean up database tables that are bloated with excessive old data, so that database applications can continue to operate reliably and efficiently.

Oracle database provides database administrators with a useful tool – “Purge”, which makes it easy to manage database purging tasks. Oracle database has two types of tables: permanent tables and temporary tables. In order to permanently remove unused data from a permanent table, a “purge SQL statement” must be executed. The statement will identify the records to be deleted from the database and then remove those records from the table. This purging process needs to be completed periodically.

The best way to purge Oracle database is to use the “PURGE” SQL statement. This command enables you to specify a specific date range for the rows to clean from the database. This statement takes the following values:

PURGE {TABLENAME | TABLE_NAME | COLUMN_NAME }{BETWEEN date1 and date2}

where date1 and date2 are the starting and ending date of the rows to be cleaned. For instance, this command deletes all the rows in a table, whose date is before 2020-07-01:

PURGE table_name BETWEEN ‘2020-01-01’ and ‘2020-07-01’;

If the SQL statement includes more than two dates, the records between the two dates and before the first date will be kept. To delete records beyond a specific month, we can use the month function:

PURGE table_name BETWEEN

Month(date1, 12)

and

Month(date2, 12);

Besides SQL statement, Oracle database also provides a “Purge Table” feature which can be used to delete all the records from a table permanently:

ALTER TABLE table_name PURGE;

In conclusion, database purging is an important task for the maintenance of a database. Oracle database provides various tools and statements to help administrators to manage their databases. Therefore, it is essential for database administrators to purging their database regularly in order to maintain their applications’ reliability and performance.


数据运维技术 » databasePurging Unused Data from Oracle Database(purgeoracle)