To add a new configuration to the Database Cleanup utility, use the following syntax as a reference. For example, object o1 consists of table R1, which contains the following columns: col1, col2, lastupdate, and col3. To configure the Database Cleanup utility to delete all objects with col1 > 10, and where lastupdate is n days ago:
Run the following SQL statement:
insert into cleanconf (objectname, type, statement, namearg, sequence, daysarg) values ('o1', 'obsolete', 'delete from r1 where col1 > 10 and (days(CURRENT TIMESTAMP) - days(lastupdate)) > ?', 'no', 1, 'yes')
- Open a DB2 command prompt. Type the following:
db2 insert into cleanconf (objectname, type, statement, namearg, sequence, daysarg) values ('o1', 'obsolete', 'delete from r1 where col1 > 10 and (days(CURRENT TIMESTAMP) - days(lastupdate)) > ?', 'no', 1, 'yes')
- Open a DB2 command prompt. Type the following:
- Open an SQLPlus command window. Type the following:
insert into cleanconf (objectname, type, statement, namearg, sequence, daysarg) values ('o1', 'obsolete', 'delete from r1 where col1 > 10 and (sysdate - lastupdate) > ?', 'no', 1, 'yes')
- Open an SQLPlus command window. Type the following:
where ? is replaced by the -days parameter from the following command line. The 'no' indicates that the name parameter is not used in the statement. The 'yes' indicates that the -days parameter is used in the statement. 'obsolete' describes the cleanup type for object o1. You can use other words, but you must use the same word in the -type argument when you invoke the Database Cleanup utility.
Example
To invoke the Database Cleanup utility to clean the records which have been in existence for two days from the new table, type the following:
./dbclean.sh -object o1 -db dbname -type obsolete -days 2 -loglevel 1 -dbtype oracle -dbuser user -dbpasswd password
dbclean -object o1 -db dbname -type obsolete -days 2 -loglevel 1 -dbtype oracle -dbuser user -dbpasswd password
Note: For the Oracle dbname parameter, use host:port:sid. For example, myhost:1521:mydb.