SNAPDB administrative view and SNAP_GET_DB table function - Retrieve snapshot information from the dbase logical group
The SNAPDB administrative view and the SNAP_GET_DB table function return snapshot information from the database (dbase) logical group.
SNAPDB administrative view
This administrative view allows you to retrieve snapshot information from the dbase logical group for the currently connected database.
Used in conjunction with ADMIN_GET_STORAGE_PATHS table function, MON_GET_MEMORY_POOL, MON_GET_TRANSACTION_LOG, and MON_GET_HADR, the SNAPDB 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
- SELECT privilege on the SNAPDB administrative view
- CONTROL privilege on the SNAPDB administrative view
- DATAACCESS authority
- DBADM authority
- SQLADM authority
- ACCESSCTRL authority
- SECADM authority
- EXECUTE privilege on the SNAP_GET_DB table function
- DATAACCESS authority
- DBADM authority
- SQLADM authority
- SYSMON
- SYSCTRL
- SYSMAINT
- SYSADM
Default PUBLIC privilege
In a non-restrictive database, SELECT privilege is granted to PUBLIC when the view is automatically created.
Examples
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME, DBPARTITIONNUM
FROM SYSIBMADM.SNAPDB ORDER BY DBPARTITIONNUM
DB_NAME DB_STATUS SERVER_PLATFORM DB_LOCATION ...
-------...- ------------ --------------- ------------ ...
TEST ACTIVE AIX64 LOCAL ...
TEST ACTIVE AIX64 LOCAL ...
TEST ACTIVE AIX64 LOCAL ...
3 record(s) selected.
... DB_CONN_TIME DBPARTITIONNUM
... -------------------------- --------------
... 2006-01-08-16.48.30.665477 0
... 2006-01-08-16.48.34.005328 1
... 2006-01-08-16.48.34.007937 2
SELECT TOTAL_OLAP_FUNCS, OLAP_FUNC_OVERFLOWS, ACTIVE_OLAP_FUNCS
FROM SYSIBMADM.SNAPDB
TOTAL_OLAP_FUNCS OLAP_FUNC_OVERFLOWS ACTIVE_OLAP_FUNCS
-------------------- -------------------- -----------------
7 2 1
1 record(s) selected.
SELECT STATS_CACHE_SIZE, STATS_FABRICATIONS, SYNC_RUNSTATS,
ASYNC_RUNSTATS, STATS_FABRICATE_TIME, SYNC_RUNSTATS_TIME
FROM SYSIBMADM.SNAPDB
STATS_CACHE_SIZE STATS_FABRICATIONS SYNC_RUNSTATS ASYNC_RUNSTATS ...
---------------- ------------------ ------------- -------------- ...
128 2 1 0 ...
... STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
... -------------------- ------------------
... 10 100
1 record(s) selected.
SNAP_GET_DB table function
The SNAP_GET_DB table function returns the same information as the SNAPDB administrative view.
Used in conjunction with the ADMIN_GET_STORAGE_PATHS table function, MON_GET_MEMORY_POOL, MON_GET_TRANSACTION_LOG, and MON_GET_HADR table functions, the SNAP_GET_DB 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
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.
- member
- An optional input argument of type INTEGER that specifies a valid database member number. Specify -1 for the current database member, or -2 for an aggregate of all active database members. If dbname is not set to NULL and member is set to NULL, -1 is set implicitly for member. If this input option is not used, that is, only dbname is provided, data is returned from all active database members. An active database member is a member where the database is available for connection and use by applications.
If both dbname and member 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_DB table function takes a snapshot for the currently connected database and database member number.
Authorization
- EXECUTE privilege on the SNAP_GET_DB table function
- DATAACCESS authority
- SYSMON
- SYSCTRL
- SYSMAINT
- SYSADM
Default PUBLIC privilege
In a non-restrictive database, EXECUTE privilege is granted to PUBLIC when the function is automatically created.
Examples
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME FROM TABLE(SNAP_GET_DB('', -2)) AS T
DB_NAME DB_STATUS SERVER_PLATFORM ...
-------...- ---------... --------------- ...
SAMPLE ACTIVE AIX64 ...
1 record(s) selected.
... DB_LOCATION DB_CONN_TIME
... ------------ --------------------------
... LOCAL 2005-07-24-22.09.22.013196
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME
FROM TABLE(SNAP_GET_DB(CAST (NULL AS VARCHAR(128)), -2)) AS T
DB_NAME DB_STATUS SERVER_PLATFORM ...
--------...- ---------... --------------- ...
TOOLSDB ACTIVE AIX64 ...
SAMPLE ACTIVE AIX64 ...
... DB_LOCATION DB_CONN_TIME
... ------------ --------------------------
... LOCAL 2005-07-24-22.26.54.396335
... LOCAL 2005-07-24-22.09.22.013196
Example 3: This routine can be used by calling the following on the command line:
SELECT TOTAL_OLAP_FUNCS, OLAP_FUNC_OVERFLOWS, ACTIVE_OLAP_FUNCS
FROM TABLE (SNAP_GET_DB('', 0)) AS T
The output will look like:
TOTAL_OLAP_FUNCS OLAP_FUNC_OVERFLOWS ACTIVE_OLAP_FUNCS
---------------- -------------------- --------------------
7 2 1
1 record(s) selected.
SELECT STATS_CACHE_SIZE, STATS_FABRICATIONS, SYNC_RUNSTATS,
ASYNC_RUNSTATS, STATS_FABRICATE_TIME, SYNC_RUNSTATS_TIME
FROM TABLE (SNAP_GET_DB('mytestdb', -1)) AS SNAPDB
STATS_CACHE_SIZE STATS_FABRICATIONS SYNC_RUNSTATS ASYNC_RUNSTATS ...
---------------- ------------------ ------------- -------------- ...
200 1 2 0 ...
Continued
...STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
...-------------------- ------------------
... 2 32
1 record(s) selected.
SELECT SUBSTR
(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS
FROM table(SNAP_GET_DB('hadrdb', 0))
DB_NAME DB_STATUS
-------------------- ----------------
HADRDB ACTIVE_STANDBY