Used to delete entries from the recovery history file or to delete log files from the active log file path. Deleting entries from the recovery history file might be necessary if the file becomes excessively large and the retention period is high.
In a partitioned environment, the PRUNE HISTORY command only performs on the database partition it is issued on. To prune the history on multiple partitions, you can either issue the PRUNE HISTORY command from each individual database partition, or use the db2_all prefix to run the PRUNE HISTORY command on all database partitions.
Database
>>-PRUNE--------------------------------------------------------> >--+-HISTORY--timestamp--+-------------------+--+------------+-+->< | '-WITH FORCE OPTION-' '-AND DELETE-' | '-LOGFILE PRIOR TO--log-file-name---------------------------'
If you set the auto_del_rec_obj database configuration parameter to ON, calling PRUNE HISTORY with the AND DELETE parameter will also physically delete backup images and load copy images if their history file entry is pruned.
db2 prune history 199412
199412 is interpreted as 19941201000000.
If the WITH FORCE OPTION is used, you might delete entries that are required for automatic restoration of databases. Manual restores will still work correctly. Use of this command can also prevent the db2ckrst utility from being able to correctly analyze the complete chain of required backup images. Using the PRUNE HISTORY command without the WITH FORCE OPTION prevents required entries from being deleted.
Those entries with status DB2HISTORY_STATUS_DO_NOT_DELETE will not be pruned. If the WITH FORCE OPTION is used, then objects marked as DB2HISTORY_STATUS_DO_NOT_DELETE will still be pruned or deleted. You can set the status of recovery history file entries to DB2HISTORY_STATUS_DO_NOT_DELETE using the UPDATE HISTORY command, the ADMIN_CMD with UPDATE_HISTORY, or the db2HistoryUpdate API. You can use the DB2HISTORY_STATUS_DO_NOT_DELETE status to prevent key recovery history file entries from being pruned and to prevent associated recovery objects from being deleted.
You can prune snapshot backup database history file entries using the PRUNE HISTORY command, but you cannot delete the related physical recovery objects using the AND DELETE parameter. The only way to delete snapshot backup object is to use the db2acsutil command.