DB2 Version 9.7 for Linux, UNIX, and Windows

ARCHIVE LOG command

Closes and truncates the active log file for a recoverable database.

Authorization

One of the following:
  • sysadm
  • sysctrl
  • sysmaint
  • dbadm

Required connection

None. This command establishes a database connection for the duration of the command.

Command syntax

Read syntax diagramSkip visual syntax diagram
>>-ARCHIVE LOG FOR--+-DATABASE-+--database-alias---------------->
                    '-DB-------'                   

>--+-------------------------------------+---------------------->
   '-USER--username--+-----------------+-'   
                     '-USING--password-'     

>--+-----------------------------------------+-----------------><
   '-| On Database Partition Number Clause |-'   

On Database Partition Number Clause

|--ON----------------------------------------------------------->

>--+-| Database Partition Number List Clause |----------------------------------+--|
   '-ALL DBPARTITIONNUMS--+---------------------------------------------------+-'   
                          '-EXCEPT--| Database Partition Number List Clause |-'     

Database Partition Number List Clause

|--+-DBPARTITIONNUM--+------------------------------------------>
   '-DBPARTITIONNUMS-'   

      .-,------------------------------------------------.      
      V                                                  |      
>--(----db-partition-number--+-------------------------+-+--)---|
                             '-TO--db-partition-number-'        

Command parameters

DATABASE database-alias
Specifies the alias of the database whose active log is to be archived.
USER username
Identifies the user name under which a connection will be attempted.
USING password
Specifies the password to authenticate the user name.
ON ALL DBPARTITIONNUMS
Specifies that the command should be issued on all database partitions in the db2nodes.cfg file. This is the default if a database partition number clause is not specified.
EXCEPT
Specifies that the command should be issued on all database partitions in the db2nodes.cfg file, except those specified in the database partition number list.
ON DBPARTITIONNUM | ON DBPARTITIONNUMS
Specifies that the logs should be archived for the specified database on a set of database partitions.
db-partition-number
Specifies a database partition number in the database partition number list.
TO db-partition-number
Used when specifying a range of database partitions for which the logs should be archived. All database partitions from the first database partition number specified up to and including the second database partition number specified are included in the database partition number list.

Usage notes

This command can be used to collect a complete set of log files up to a known point. The log files can then be used to update a standby database.

This command can only be executed when the invoking application or shell does not have a database connection to the specified database. This prevents a user from executing the command with uncommitted transactions. As such, the ARCHIVE LOG command will not forcibly commit the user's incomplete transactions. If the invoking application or shell already has a database connection to the specified database, the command will terminate and return an error. If another application has transactions in progress with the specified database when this command is executed, there will be a slight performance degradation since the command flushes the log buffer to disk. Any other transactions attempting to write log records to the buffer will have to wait until the flush is complete.

If used in a partitioned database environment, a subset of database partitions can be specified by using a database partition number clause. If the database partition number clause is not specified, the default behavior for this command is to close and archive the active log on all database partitions.

Using this command will use up a portion of the active log space due to the truncation of the active log file. The active log space will resume its previous size when the truncated log becomes inactive. Frequent use of this command can drastically reduce the amount of the active log space available for transactions.

The ARCHIVE LOG command is asynchronous. When you issue the ARCHIVE LOG command, the log is closed, making it viable for archiving. The log is not archived immediately; there might be a delay between the time when you submit the command and the time when the log is archived. Archiving itself of the log is done by the db2logmgr process. This delay is particularly apparent if you deactivate a database immediately after issuing the ARCHIVE LOG command. The log may not archive until the next database activation.

Compatibilities

For compatibility with versions earlier than Version 8:
  • The keyword NODE can be substituted for DBPARTITIONNUM.
  • The keyword NODES can be substituted for DBPARTITIONNUMS.