DB2 Version 9.7 for Linux, UNIX, and Windows

SNAPDETAILLOG administrative view and SNAP_GET_DETAILLOG_V91 table function - Retrieve snapshot information from the detail_log logical data group

The SNAPDETAILLOG administrative view and the SNAP_GET_DETAILLOG_V91 table function return snapshot information from the detail_log logical data group.

SNAPDETAILLOG administrative view

This administrative view allows you to retrieve snapshot information from the detail_log logical data group for the currently connected database.

Used in conjunction with the SNAPDB, SNAPDB_MEMORY_POOL, SNAPHADR and SNAPSTORAGE_PATHS administrative views, the SNAPDETAILLOG administrative view provides information equivalent to the GET SNAPSHOT FOR DATABASE on database-alias CLP command.

The schema is SYSIBMADM.

Refer to Table 1 for a complete list of information that is returned.

Authorization

One of the following authorizations is required:
  • SELECT privilege on the SNAPDETAILLOG administrative view
  • CONTROL privilege on the SNAPDETAILLOG administrative view
  • DATAACCESS authority
In addition, one of the following privileges or authorities is also required:
  • EXECUTE privilege on the SNAP_GET_DETAILLOG_V91 table function
  • DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
  • SYSMON
  • SYSCTRL
  • SYSMAINT
  • SYSADM

Example

Retrieve log information for all database partitions for the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 8) AS DB_NAME, FIRST_ACTIVE_LOG, 
   LAST_ACTIVE_LOG, CURRENT_ACTIVE_LOG, CURRENT_ARCHIVE_LOG, 
   DBPARTITIONNUM 
   FROM SYSIBMADM.SNAPDETAILLOG ORDER BY DBPARTITIONNUM
The following example is a sample output from this query.
DB_NAME  FIRST_ACTIVE_LOG     LAST_ACTIVE_LOG      ...
-------- -------------------- -------------------- ...
TEST                        0                    8 ...
TEST                        0                    8 ...
TEST                        0                    8 ...

  3 record(s) selected.
Output from this query (continued).
... CURRENT_ACTIVE_LOG   CURRENT_ARCHIVE_LOG  DBPARTITIONNUM
... -------------------- -------------------- --------------
...                    0                    -              0
...                    0                    -              1
...                    0                    -              2

SNAP_GET_DETAILLOG_V91 table function

The SNAP_GET_DETAILLOG_V91 table function returns the same information as the SNAPDETAILLOG administrative view.

Used in conjunction with the SNAP_GET_DB_V95, SNAP_GET_DB_MEMORY_POOL, SNAP_GET_HADR and SNAP_GET_STORAGE_PATHS table functions, the SNAP_GET_DETAILLOG table function provides information equivalent to the GET SNAPSHOT FOR ALL DATABASES CLP command.

Refer to Table 1 for a complete list of information that is returned.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-SNAP_GET_DETAILLOG_V91--(--dbname--+------------------+--)--><
                                      '-, dbpartitionnum-'      

The schema is SYSPROC.

Table function parameters

dbname
An input argument of type VARCHAR(128) that specifies a valid database name in the same instance as the currently connected database. Specify a database name that has a directory entry type of either "Indirect" or "Home", as returned by the LIST DATABASE DIRECTORY command. Specify an empty string to take the snapshot from the currently connected database. Specify a NULL value to take the snapshot from all databases within the same instance as the currently connected database.
dbpartitionnum
An optional input argument of type INTEGER that specifies a valid database partition number. Specify -1 for the current database partition, or -2 for an aggregate of all active database partitions. If dbname is not set to NULL and dbpartitionnum is set to NULL, -1 is set implicitly for dbpartitionnum. If this input option is not used, that is, only dbname is provided, data is returned from all active database partitions. An active database partition is a partition where the database is available for connection and use by applications.

If both dbname and dbpartitionnum are set to NULL, an attempt is made to read data from the file created by SNAP_WRITE_FILE procedure. Note that this file could have been created at any time, which means that the data might not be current. If a file with the corresponding snapshot API request type does not exist, then the SNAP_GET_DETAILLOG_V91 table function takes a snapshot for the currently connected database and database partition number.

Authorization

One of the following authorizations is required:
  • EXECUTE privilege on the SNAP_GET_DETAILLOG_V91 table function
  • DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
  • SYSMON
  • SYSCTRL
  • SYSMAINT
  • SYSADM

Example

Retrieve log information for database partition 1 for the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 8) AS DB_NAME, FIRST_ACTIVE_LOG, 
   LAST_ACTIVE_LOG, CURRENT_ACTIVE_LOG, CURRENT_ARCHIVE_LOG 
   FROM TABLE(SNAP_GET_DETAILLOG_V91('', 1)) AS T
The following example is a sample output from this query.
DB_NAME  FIRST_ACTIVE_LOG     LAST_ACTIVE_LOG      ...
-------- -------------------- -------------------- ...
TEST                        0                    8 ...

  1 record(s) selected.
Output from this query (continued).
... CURRENT_ACTIVE_LOG   CURRENT_ARCHIVE_LOG 
... -------------------- --------------------
...                    0                    -

SNAPDETAILLOG administrative view and SNAP_GET_DETAILLOG_V91 table function metadata

Table 1. Information returned by the SNAPDETAILLOG administrative view and SNAP_GET_DETAILLOG_V91 table function
Column name Data type Description or corresponding monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP snapshot_timestamp - Snapshot timestamp monitor element
DB_NAME VARCHAR(128) db_name - Database name
FIRST_ACTIVE_LOG BIGINT first_active_log - First active log file number
LAST_ACTIVE_LOG BIGINT last_active_log - Last active log file number
CURRENT_ACTIVE_LOG BIGINT current_active_log - Current active log file number
CURRENT_ARCHIVE_LOG BIGINT current_archive_log - Current archive log file number
DBPARTITIONNUM SMALLINT The database partition from which the data was retrieved for this row.