ARCHIVE LOG command

The ARCHIVE LOG command closes and truncates the active log file for a recoverable database.

Authorization

One of the following authorities:
  • 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 diagramARCHIVE LOG FORDATABASEDBdatabase-aliasUSERusernameUSINGpassword On Database Partition Number Clause
On Database Partition Number Clause
Read syntax diagramSkip visual syntax diagramONDatabase Partition Number List ClauseALL DBPARTITIONNUMSEXCEPTDatabase Partition Number List Clause
Database Partition Number List Clause
Read syntax diagramSkip visual syntax diagramDBPARTITIONNUMDBPARTITIONNUMS (,db-partition-numberTOdb-partition-number)

Command parameters

DATABASE database-alias
Specifies the alias of the database whose active log is to be archived.
USER username
Specifies 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

  • The ARCHIVE LOG command can be used to collect a complete set of log data up to a known point. The log data can then be used to update a standby database.
  • If log data resides in the middle of a log file when the ARCHIVE LOG command is run, then the log file is truncated. Logging continues on the next file.
  • The ARCHIVE LOG command can only be run when the invoking application or shell does not have a database connection to the specified database. This safeguard prevents a user from running the ARCHIVE LOG command with uncommitted transactions. As such, the ARCHIVE LOG command does not forcibly commit the user's incomplete transactions. If the invoking application or shell already has a database connection to the specified database, then the command returns an error. If another application has transactions in progress with the specified database when the ARCHIVE LOG command is run, a slight performance degradation happens when the ARCHIVE LOG command flushes the log buffer to disk. Any other transactions attempting to write log records to the buffer must 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 the ARCHIVE LOG command is to close and archive the active log on all database partitions.
  • Running the ARCHIVE LOG command consumes a portion of the active log space, due to the truncation of the active log file. The active log space resumes its previous size when the truncated log becomes inactive. Frequent use of the ARCHIVE LOG command can reduce the amount of the active log space available for transactions, and can generate an SQL0964C error if sufficient log space is unavailable.
  • The ARCHIVE LOG command is asynchronous. When you issue the ARCHIVE LOG command, the log is closed, making it available for archiving. The log is not archived immediately; A delay can happen between the time when a command is submitted and the time when the log is archived. This delay is seen if you deactivate a database immediately after issuing the ARCHIVE LOG command, because the log might not archive until the next database activation.

    The request is distributed to every member to which the database has access when issuing the ARCHIVE LOG command or invoking the db2ArchiveLog API in a Db2 pureScale® environment. If a member is consistent (either online or offline), the ARCHIVE LOG command skips that member, since the last log file of the member is already truncated from when the member last shut down cleanly. If an offline member is not consistent, then ARCHIVE LOG waits for member crash recovery (MCR) to complete before truncation.