DB 2 Are 951
DB 2 Are 951
5
for Linux, UNIX, and Windows
SC23-5843-01
DB2 Version 9.5
for Linux, UNIX, and Windows
SC23-5843-01
Note
Before using this information and the product it supports, read the general information under Appendix B, “Notices,” on
page 817.
Edition Notice
This document contains proprietary information of IBM. It is provided under a license agreement and is protected
by copyright law. The information contained in this publication does not include any product warranties, and any
statements provided in this manual should not be interpreted as such.
You can order IBM publications online or through your local IBM representative.
v To order publications online, go to the IBM Publications Center at www.ibm.com/shop/publications/order
v To find your local IBM representative, go to the IBM Directory of Worldwide Contacts at www.ibm.com/
planetwide
To order DB2 publications from DB2 Marketing and Sales in the United States or Canada, call 1-800-IBM-4YOU
(426-4968).
When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any
way it believes appropriate without incurring any obligation to you.
© Copyright International Business Machines Corporation 2006, 2008. All rights reserved.
US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract
with IBM Corp.
Contents
Part 1. Administrative SQL routines AUTOMAINT_GET_POLICYFILE procedure -
retrieve automatic maintenance policy . . . . 210
and views . . . . . . . . . . . . . 1 AUTOMAINT_SET_POLICY procedure -
configure automatic maintenance policy . . . 211
Chapter 1. Authorization for AUTOMAINT_SET_POLICYFILE procedure -
administrative views . . . . . . . . . 3 configure automatic maintenance policy . . . 212
Configuration routines and views . . . . . . 213
Chapter 2. Administrative views versus DB_PARTITIONS . . . . . . . . . . . 213
DBCFG administrative view - Retrieve database
table functions . . . . . . . . . . . . 5 configuration parameter information . . . . 214
DBMCFG administrative view - Retrieve
Chapter 3. Supported administrative database manager configuration parameter
SQL routines and views . . . . . . . . 7 information . . . . . . . . . . . . . 216
Activity monitor routines . . . . . . . . . . 19 REG_VARIABLES administrative view -
AM_BASE_RPT_RECOMS – Recommendations Retrieve DB2 registry settings in use. . . . . 219
for activity reports . . . . . . . . . . . 19 Environment views . . . . . . . . . . . 220
AM_BASE_RPTS – Activity monitor reports . . 20 ENV_INST_INFO administrative view - Retrieve
AM_DROP_TASK – Delete a monitoring task . . 21 information about the current instance . . . . 220
AM_GET_LOCK_CHN_TB – Retrieve application ENV_PROD_INFO administrative view -
lock chain data in a tabular format . . . . . 22 Retrieve information about installed DB2
AM_GET_LOCK_CHNS – Retrieve lock chain products . . . . . . . . . . . . . . 221
information for a specific application . . . . . 23 ENV_FEATURE_INFO administrative view -
AM_GET_LOCK_RPT – Retrieve application lock Return license information for DB2 features . . 223
details . . . . . . . . . . . . . . . 24 ENV_SYS_INFO administrative view - Retrieve
AM_GET_RPT – Retrieve activity monitor data 31 information about the system . . . . . . . 224
AM_SAVE_TASK – Create or modify a ENV_SYS_RESOURCES administrative view -
monitoring task . . . . . . . . . . . . 32 Return system information . . . . . . . . 225
ADMIN_CMD procedure and associated routines . 33 Health snapshot routines . . . . . . . . . 228
ADMIN_CMD – Run administrative commands 33 HEALTH_CONT_HI . . . . . . . . . . 228
ADMIN_GET_DBP_MEM_USAGE table HEALTH_CONT_HI_HIS . . . . . . . . 230
function - Get total memory consumption for HEALTH_CONT_INFO . . . . . . . . . 232
instance . . . . . . . . . . . . . . 191 HEALTH_DB_HI . . . . . . . . . . . 233
ADMIN_GET_MSGS table function - Retrieve HEALTH_DB_HI_HIS . . . . . . . . . 236
messages generated by a data movement utility HEALTH_DB_HIC . . . . . . . . . . 240
that is executed through the ADMIN_CMD HEALTH_DB_HIC_HIS . . . . . . . . . 242
procedure . . . . . . . . . . . . . 193 HEALTH_DB_INFO . . . . . . . . . . 244
ADMINTABCOMPRESSINFO view and HEALTH_DBM_HI . . . . . . . . . . 246
ADMIN_GET_TAB_COMPRESS_INFO . . . . 194 HEALTH_DBM_HI_HIS . . . . . . . . . 247
ADMIN_REMOVE_MSGS procedure - Clean up HEALTH_DBM_INFO . . . . . . . . . 249
messages generated by a data movement utility HEALTH_GET_ALERT_ACTION_CFG table
that is executed through the ADMIN_CMD function -Retrieve health alert action
procedure . . . . . . . . . . . . . 199 configuration settings. . . . . . . . . . 250
ADMINTABINFO administrative view and HEALTH_GET_ALERT_CFG table function -
ADMIN_GET_TAB_INFO_V95 table function - Retrieve health alert configuration settings . . 253
Retrieve size and state information for tables . . 199 HEALTH_GET_IND_DEFINITION table
Audit routines and procedures . . . . . . . 206 function - Retrieve health indicator definitions . 256
AUDIT_ARCHIVE procedure and table function HEALTH_HI_REC . . . . . . . . . . . 258
- Archive audit log file . . . . . . . . . 206 HEALTH_TBS_HI . . . . . . . . . . . 260
AUDIT_DELIM_EXTRACT - performs extract to HEALTH_TBS_HI_HIS . . . . . . . . . 262
delimited file . . . . . . . . . . . . 207 HEALTH_TBS_INFO . . . . . . . . . . 266
AUDIT_LIST_LOGS table function - Lists MQSeries routines . . . . . . . . . . . . 267
archived audit log files . . . . . . . . . 208 MQPUBLISH . . . . . . . . . . . . 267
Automatic maintenance routines . . . . . . . 209 MQREAD . . . . . . . . . . . . . 269
AUTOMAINT_GET_POLICY procedure - MQREADALL . . . . . . . . . . . . 270
retrieve automatic maintenance policy . . . . 209 MQREADALLCLOB . . . . . . . . . . 272
MQREADCLOB . . . . . . . . . . . 274
Contents v
SNAPSWITCHES administrative view and CAPTURE_STORAGEMGMT_INFO procedure -
SNAP_GET_SWITCHES table function – Retrieve storage-related information for a given
Retrieve database snapshot switch state root object . . . . . . . . . . . . . 584
information . . . . . . . . . . . . . 533 CREATE_STORAGEMGMT_TABLES procedure
SNAPTAB administrative view and - Create storage management tables . . . . . 585
SNAP_GET_TAB_V91 table function - Retrieve DROP_STORAGEMGMT_TABLES procedure -
table logical data group snapshot information . 536 Drop all storage management tables . . . . . 586
SNAPTAB_REORG administrative view and Text Search routines . . . . . . . . . . . 587
SNAP_GET_TAB_REORG table function - SYSTS_ADMIN_CMD stored procedure - Run
Retrieve table reorganization snapshot text search administration commands . . . . 587
information . . . . . . . . . . . . . 539 SYSTS_ALTER procedure - Change the update
SNAPTBSP administrative view and characteristics of an index . . . . . . . . 588
SNAP_GET_TBSP_V91 table function - Retrieve SYSTS_CLEAR_COMMANDLOCKS procedure -
table space logical data group snapshot Remove command locks for text search indexes . 591
information . . . . . . . . . . . . . 543 SYSTS_CLEAR_EVENTS procedure - Delete
SNAPTBSP_PART administrative view and indexing events from an index’s event table . . 593
SNAP_GET_TBSP_PART_V91 table function - SYSTS_CREATE procedure - Create a text search
Retrieve tablespace_nodeinfo logical data group index on a column . . . . . . . . . . 595
snapshot information . . . . . . . . . . 548 SYSTS_DISABLE procedure - Disable current
SNAPTBSP_QUIESCER administrative view and database for text search . . . . . . . . . 601
SNAP_GET_TBSP_QUIESCER table function - SYSTS_DROP procedure - Drop a text search
Retrieve quiescer table space snapshot index . . . . . . . . . . . . . . . 603
information . . . . . . . . . . . . . 553 SYSTS_ENABLE procedure - Enable current
SNAPTBSP_RANGE administrative view and database for text search . . . . . . . . . 605
SNAP_GET_TBSP_RANGE table function - SYSTS_UPDATE procedure - Update the text
Retrieve range snapshot information . . . . 556 search index . . . . . . . . . . . . . 607
SNAPUTIL administrative view and Workload Management routines . . . . . . . 609
SNAP_GET_UTIL table function - Retrieve WLM_CANCEL_ACTIVITY - Cancel an activity 609
utility_info logical data group snapshot WLM_CAPTURE_ACTIVITY_IN_PROGRESS -
information . . . . . . . . . . . . . 559 Collect activity information for activities event
SNAPUTIL_PROGRESS administrative view monitor . . . . . . . . . . . . . . 610
and SNAP_GET_UTIL_PROGRESS table WLM_COLLECT_STATS - Collect and reset
function - Retrieve progress logical data group workload management statistics . . . . . . 612
snapshot information . . . . . . . . . . 563 WLM_GET_ACTIVITY_DETAILS - Return
SNAP_WRITE_FILE procedure . . . . . . 565 detailed information about a specific activity . . 613
TBSP_UTILIZATION administrative view - WLM_GET_QUEUE_STATS table function -
Retrieve table space configuration and Return threshold queue statistics . . . . . . 619
utilization information . . . . . . . . . 566 WLM_GET_SERVICE_CLASS_AGENTS - List
TOP_DYNAMIC_SQL administrative view - agents executing in a service class . . . . . 623
Retrieve information on the top dynamic SQL WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES
statements . . . . . . . . . . . . . 570 - List of workload occurrences . . . . . . . 627
SQL procedures routines . . . . . . . . . 571 WLM_GET_SERVICE_SUBCLASS_STATS -
GET_ROUTINE_OPTS . . . . . . . . . 571 Return statistics of service subclasses . . . . 631
GET_ROUTINE_SAR . . . . . . . . . . 571 WLM_GET_SERVICE_SUPERCLASS_STATS -
PUT_ROUTINE_SAR . . . . . . . . . . 572 Return statistics of service superclasses . . . . 636
REBIND_ROUTINE_PACKAGE . . . . . . 573 WLM_GET_WORK_ACTION_SET_STATS -
SET_ROUTINE_OPTS . . . . . . . . . 574 Return work action set statistics . . . . . . 638
Stepwise redistribute routines . . . . . . . . 575 WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES
ANALYZE_LOG_SPACE procedure - Retrieve - Return a list of activities . . . . . . . . 640
log space analysis information . . . . . . . 575 WLM_GET_WORKLOAD_STATS - Return
GENERATE_DISTFILE procedure - Generate a workload statistics . . . . . . . . . . . 644
data distribution file . . . . . . . . . . 577 WLM_SET_CLIENT_INFO procedure - Set client
GET_SWRD_SETTINGS procedure - Retrieve information . . . . . . . . . . . . . 646
redistribute information . . . . . . . . . 578 Miscellaneous routines and views . . . . . . 648
SET_SWRD_SETTINGS procedure - Create or ADMIN_COPY_SCHEMA procedure - Copy a
change redistribute registry . . . . . . . . 580 specific schema and its objects . . . . . . . 648
STEPWISE_REDISTRIBUTE_DBPG procedure - ADMIN_DROP_SCHEMA procedure - Drop a
Redistribute part of database partition group . . 582 specific schema and its objects . . . . . . . 652
Storage management tool routines . . . . . . 584 ALTOBJ . . . . . . . . . . . . . . 654
APPLICATION_ID . . . . . . . . . . 656
Contents vii
viii Administrative Routines and Views
Part 1. Administrative SQL routines and views
The administrative routines and views provide a primary, easy to use
programmatic interface to administer DB2® through SQL. They encompass a
collection of built-in views, table functions, procedures, and scalar functions for
performing a variety of DB2 administrative tasks. For example: reorganizing a
table, capturing and retrieving monitor data or retrieving the application ID of the
current connection.
These routines and views can be invoked from an SQL-based application, a DB2
command line or a command script.
The administrative views are the preferred and only documented interfaces for the
views based on catalog views and the views based on table functions with no
input parameters because the table functions do not provide any additional
information or performance benefits.
For administrative views based on table functions with one or more input
parameters, both the administrative view and the table function can be used, each
achieving a different goal:
v The ADMINTABINFO administrative view and the
ADMIN_GET_TAB_INFO_V95 table function: The administrative view retrieves
information for all tables in the database. This can have a significant
performance impact for large databases. The performance impact can be reduced
by using the table function and specifying a schema name, table name, or both
as input.
v The PDLOGMSGS_LAST24HOURS administrative view and the
PD_GET_LOG_MSGS table function: The administrative view, which retrieves
notification log messages, provides quick access to data from the previous 24
hours, whereas the table function allows you to retrieve data from a specified
period of time.
v All snapshot monitor administrative views and table functions (SNAP*
administrative views, SNAP_GET_* table functions): The snapshot monitor
administrative views provide access to data from each database partition. The
table functions provide the option to choose between data from a single
database partition or data aggregated across all database partitions.
Applications that use the table functions instead of the views might need to be
changed because the table functions might change from release to release to enable
new information to be returned. The new table function will have the same base
name as the original function and will be suffixed with ’_Vxx’ for the version of
the product in which it is added (for example, _V95). The administrative views
will always be based on the most current version of the table functions, and
therefore allow for more application portability. Since the columns might vary from
one release to the next, it is recommended that specific columns be selected from
the administrative views, or that the result set be described if a SELECT *
statement is used by an application.
Syntax
AM_BASE_RPT_RECOMS ( report-id , client-locale )
Authorization
Example 1: Request recommendations (in English) for the activity monitor report
with an ID of 1. Assume the default client language identifier ’En_US’.
SELECT *
FROM TABLE(SYSPROC.AM_BASE_RPT_RECOMS(1, CAST(NULL AS VARCHAR(33))))
AS RECOMS
Example 2: Request recommendations (in French) for the activity monitor report
with an ID of 12.
SELECT *
FROM TABLE(SYSPROC.AM_BASE_RPT_RECOMS(12, CAST(’Fr_FR’ AS VARCHAR(33))))
AS RECOMS
Information returned
Table 17. Information returned by the AM_BASE_RPT_RECOMS table function
Column name Data type Description
REPORT_ID INTEGER The report ID.
RECOM_NAME VARCHAR(256) The name or short
description of the
recommendation.
RECOM_DESCRIPTION CLOB(32K) The detailed description of
the recommendation.
Syntax
AM_BASE_RPTS ( report-id , type , client-locale )
Authorization
Examples
Example 1:
SELECT * FROM TABLE(SYSPROC.AM_BASE_RPTS(CAST(NULL AS INTEGER),
CAST(NULL AS CHAR(4)), CAST(NULL AS VARCHAR(33)))) AS REPORTS
Example 2:
SELECT ID, NAME FROM TABLE(SYSPROC.AM_BASE_RPTS(
CAST(NULL AS INTEGER), CAST(’STMT’ AS CHAR(4)), ’En_US’))
AS REPORTS WHERE TYPE = ’STMT’
Information returned
Table 18. Information returned by the AM_BASE_RPTS table function
Column name Data type Description
ID INTEGER The unique report ID.
TYPE CHAR(4) The report type. Valid values
are: APPL, STMT, TRAN,
CACH.
NAME VARCHAR(256) The name or short
description of the report.
DESCRIPTION VARCHAR(16384) The detailed description of
the report.
SWITCHES VARCHAR(100) The monitor switches
required for this report.
Syntax
AM_DROP_TASK ( task-id )
Authorization
Example
Syntax
AM_GET_LOCK_CHN_TB ( agent-id )
Procedure paramater
agent-id
An input argument of type BIGINT that specifies the agent ID of the
application for which lock chain data is to be retrieved.
Authorization
v SYSMON authority
v EXECUTE privilege on the AM_GET_LOCK_CHN_TB procedure.
Example
Information returned
The procedure returns a table as shown below. Each row of the table represents a
lock-wait relationship. The result set also contains a row for each holding-only
application; in this case, the HOLDING_AGENT_ID column is null, and the other
four columns are for the holding-only application.
Table 19. Information returned by the AM_GET_LOCK_CHN_TB procedure
Column name Data Type Description
HOLDING_AGENT_ID BIGINT The agent ID of the application
holding the lock.
Syntax
AM_GET_LOCK_CHNS ( agent-id , lock-chains )
Procedure parameters
agent-id
An input argument of type BIGINT that specifies the agent ID of the
application whose lock chains are to be displayed.
lock-chains
An output argument of type CLOB(2M) that shows all the lock chains for the
specified application.
Authorization
v SYSMON authority
v EXECUTE privilege on the AM_GET_LOCK_CHNS procedure.
Example
CALL SYSPROC.AM_GET_LOCK_CHNS(17,?)
Value of output parameters
--------------------------
Parameter Name : LOCK_CHAINS
Parameter Value : >db2bp.exe (Agent ID: 17) (Auth ID: AMUSERC )
Return Status = 0
Syntax
AM_GET_LOCK_RPT ( agent-id )
Procedure parameter
agent-id
An input argument of type BIGINT that specifies the agent ID of the
application whose lock details are to be returned.
Authorization
v SYSMON authority
v EXECUTE privilege on the AM_GET_LOCK_RPT procedure.
Example
CALL SYSPROC.AM_GET_LOCK_RPT(68)
Usage note
The DFT_MON_LOCK monitor switch must be turned on for this procedure to
return any information.
Information returned
The procedure returns three result sets: one for application general information;
one for locks that the application holds; and one for locks that the application is
waiting for.
Table 20. General application information returned by the AM_GET_LOCK_RPT procedure
Column name Data Type Description
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
APPL_NAME VARCHAR(256) appl_name - Application name
AUTH_ID VARCHAR(128) auth_id - Authorization ID
APPL_ID VARCHAR(128) appl_id - Application ID
Syntax
AM_GET_RPT ( database partition , report-id , appl-filter ,
max-number )
Procedure parameters
database partition
An input argument of type INTEGER that specifies a database partition
number. Valid values are -2 (denoting all database partitions) and the database
partition number of any existing database partition.
report-id
An input argument of type INTEGER that specifies a unique report ID.
appl-filter
An input argument of type CLOB(32K) that specifies an application filter. An
application filter is a search condition involving any or all of the three columns
AGENT_ID, APPL_NAME, and AUTH_ID, where AGENT_ID and AUTH_ID
are integers, and APPL_NAME is a character string. If the argument is null or
an empty string, no filtering is performed.
max-number
An input argument of type INTEGER that specifies the maximum number of
Authorization
v SYSMON authority
v EXECUTE privilege on the AM_GET_RPT procedure.
Example
CALL SYSPROC.AM_GET_RPT(-2, 18,
CAST(’AGENT_ID=29 AND AUTH_ID <> ’’dbuser’’ AND APPL_NAME LIKE ’’db2%’’’
AS CLOB(32K)), 100)
Usage note
The result set returned is different for each report id. This procedure is intended to
support the Activity Monitor graphical tool. To build reports that can be parsed,
snapshot administrative SQL routines and views should be used instead.
Syntax
AM_SAVE_TASK ( mode , task-id , task-name , appl-filter ,
show-lock-chains , report-ids )
Procedure parameters
mode
An input argument of type CHAR(1) that specifies whether to create a new
monitoring task (’C’) or to modify an existing monitoring task (’M’).
task-id
An input argument of type INTEGER that specifies a unique monitoring task
ID. When mode is ’C’, any specified input for task-id is ignored. An ID for the
new monitoring task will be generated by the procedure and returned in the
output. When mode is ’M’, specifies the ID of the monitoring task that is being
modified.
task-name
An input argument of type VARCHAR(128) that specifies a name or short
description for a monitoring task.
appl-filter
An input argument of type CLOB(32K) that specifies an application filter. An
application filter is a search condition involving any or all of the three columns
AGENT_ID, APPL_NAME, and AUTH_ID, where AGENT_ID and AUTH_ID
are integers, and APPL_NAME is a character string. If the argument is null or
an empty string, no filtering is performed.
Authorization
Example
Example:
CALL SYSPROC.AM_SAVE_TASK(’M’,11,’Task ABC’,CAST (NULL AS CLOB(32K)),
’N’,’1,2,4,8,9,12’)
Syntax
ADMIN_CMD ( command-string )
Procedure parameter
command-string
An input argument of type CLOB (2M) that specifies a single command that is
to be executed.
Authorization
The procedure currently supports the following DB2 command line processor
(CLP) commands:
v ADD CONTACT
v ADD CONTACTGROUP
v AUTOCONFIGURE
v BACKUP - online only
v DESCRIBE
v DROP CONTACT
v DROP CONTACTGROUP
v EXPORT
v FORCE APPLICATION
Note: Some commands might have slightly different supported syntax when
executed through the ADMIN_CMD procedure.
The procedure also supports the following commands which are not supported by
the CLP:
v GET STMM TUNING DBPARTITIONNUM
v UPDATE STMM TUNING DBPARTITIONNUM
Usage notes
v The result sets can be retrieved from the CLP or from applications such as JDBC
and DB2 CLI applications, but not from embedded C applications.
For all commands executed through the ADMIN_CMD, the user ID that
established the connection to the database is used for authentication.
Any additional authority required, for example, for commands that need file
system access on the database server, is documented in the reference information
describing the command.
Authorization
None
Required connection
Command syntax
Command parameters
ADD CONTACT name
The name of the contact that will be added. By default the contact will be
added in the local system, unless the DB2 administration server
configuration parameter contact_host points to another system.
TYPE Method of contact, which must be one of the following two:
EMAIL
This contact wishes to be notified by e-mail at (ADDRESS).
PAGE This contact wishes to be notified by a page sent to ADDRESS.
MAXIMUM PAGE LENGTH pg-length
If the paging service has a message-length restriction, it is
specified here in characters.
Example
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Authorization
None
Required connection
Command Syntax
DESCRIPTION group description
Command Parameters
ADD CONTACTGROUP name
Name of the new contact group, which must be unique among the set of
groups on the system.
CONTACT name
Name of the contact which is a member of the group. A contact can be
defined with the ADD CONTACT command after it has been added to a
group.
GROUP name
Name of the contact group of which this group is a member.
DESCRIPTION group description
Optional. A textual description of the contact group.
Example
Create a contact group named ’gname1’ that contains two contacts: ’cname1’ and
’cname2’.
CALL SYSPROC.ADMIN_CMD( ’add contactgroup gname1 contact cname1, contact cname2’ )
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Authorization
sysadm
Required connection
Database
Command syntax
AUTOCONFIGURE
APPLY DB ONLY
DB AND DBM ON CURRENT NODE
NONE
Command parameters
USING input-keyword param-value
Table 24. Valid input keywords and parameter values
Keyword Valid values Default value Explanation
mem_percent 1–100 25 Percentage of
memory to dedicate.
If other applications
(other than the
operating system) are
running on this
server, set this to less
than 100.
workload_type simple, mixed, mixed Simple workloads
complex tend to be I/O
intensive and mostly
transactions, whereas
complex workloads
tend to be CPU
intensive and mostly
queries.
num_stmts 1–1 000 000 10 Number of
statements per unit
of work
tpm 1–200 000 60 Transactions per
minute
APPLY
DB ONLY
Displays the recommended values for the database configuration
and the buffer pool settings based on the current database manager
configuration. Applies the recommended changes to the database
configuration and the buffer pool settings.
DB AND DBM
Displays and applies the recommended changes to the database
manager configuration, the database configuration, and the buffer
pool settings.
NONE
Displays the recommended changes, but does not apply them.
ON CURRENT NODE
In the Database Partitioning Feature (DPF), the Configuration Advisor
updates the database configuration on all nodes by default. Running with
the ON CURRENT NODE option makes the advisor apply the
recommended database configuration to the coordinator (connection) node
only.
The bufferpool changes are always applied to the system catalogs. Thus, all
nodes are affected. The ON CURRENT NODE option does not matter for
bufferpool recommendations.
Chapter 3. Supported routines and views 39
Example
Usage notes
v On systems with multiple logical partitions, the mem_percent parameter refers
to the percentage of memory that is to be used by all logical partitions. For
example, if DB2 uses 25% of the memory on the system, specify 25% regardless
of the number of logical partitions. The database configuration recommendations
made, however, will be adjusted for one logical partition.
v This command makes configuration recommendations for the currently
connected database, assuming that the database is the only active database on
the system. If more than one database is active on the system, adjust the
mem_percent parameter to reflect the current database’s share of memory. For
example, if the DB2 database uses 80% of the system’s memory and there are
two active databases on the system that should share the resources equally,
specify 40% (80% divided by 2 databases) for the parameter mem_percent.
v When explicitly invoking the Configuration Advisor with the
AUTOCONFIGURE command, the setting of the
DB2_ENABLE_AUTOCONFIG_DEFAULT registry variable will be ignored.
v Running the AUTOCONFIGURE command on a database will recommend
enablement of the Self Tuning Memory Manager. However, if you run the
AUTOCONFIGURE command on a database in an instance where SHEAPTHRES is
not zero, sort memory tuning (SORTHEAP) will not be enabled automatically. To
enable sort memory tuning (SORTHEAP), you must set SHEAPTHRES equal to zero
using the UPDATE DATABASE MANAGER CONFIGURATION command. Note
that changing the value of SHEAPTHRES may affect the sort memory usage in your
previously existing databases.
v Command execution status is returned in the SQLCA resulting from the CALL
statement.
v SQL executed in the ADMIN_CMD procedure on behalf of AUTOCONFIGURE
is monitored by Query Patroller.
v The AUTOCONFIGURE command issues a COMMIT statement at the end if its
execution. In the case of Type-2 connections this will cause the ADMIN_CMD
procedure to return SQL30090N with reason code 2.
Command execution status is returned in the SQLCA resulting from the CALL
statement. If execution is successful, the command returns additional information
the following result set:
Scope
Authorization
Required connection
Database. The existing database connection remains after the completion of the
backup operation.
Command syntax
ON DBPARTITIONNUM Partition number(s)
DBPARTITIONNUMS
ALL DBPARTITIONNUMS
EXCEPT DBPARTITIONNUM Partition number(s)
DBPARTITIONNUMS
ONLINE
, INCREMENTAL
DELTA
TABLESPACE ( tablespace-name )
USE TSM Open sessions Options WITH num-buffers BUFFERS
XBSA
SNAPSHOT
LIBRARY library-name
LOAD library-name Open sessions Options
,
TO dir
dev
BUFFER buffer-size PARALLELISM n
Partition number(s):
( db-partition-number1 )
TO db-partition-number2
Open sessions:
Options:
OPTIONS ″options-string″
@ file-name
Command parameters
DATABASE | DB database-alias
Specifies the alias of the database to back up. The alias must be a local
database defined on the server and must be the database name that the
user is currently connected to. If the database-alias is not the one the user
is connected to, an SQL20322N error is returned.
ON Backup the database on a set of database partitions. This clause shall be
specified only on the catalog partition.
DBPARTITIONNUM db-partition-number1
Specifies a database partition number in the database partition list.
DBPARTITIONNUMS db-partition-number1 TO db-partition-number2
Specifies a range of database partition numbers, so that all
partitions from db-partition-number1 up to and including
db-partition-number2 are included in the database partition list.
ALL DBPARTITIONNUMS
Specifies that the database is to be backed up on all partitions
specified in the db2nodes.cfg file.
EXCEPT
Specifies that the database is to be backed up on all
partitions specified in the db2nodes.cfg file, except those
specified in the database partition list.
DBPARTITIONNUM db-partition-number1
Specifies a database partition number in the
database partition list.
where bufferpages is the value you want to use with the BUFFER parameter,
and ST_MAX_BUFFERS and ST_BUFFER_BLOCKS are defined in the Linux kernel
under the drivers/scsi directory.
PARALLELISM n
Determines the number of table spaces which can be read in parallel by the
backup utility. DB2 will automatically choose an optimal value for this
parameter unless you explicitly enter a value.
UTIL_IMPACT_PRIORITY priority
Specifies that the backup will run in throttled mode, with the priority
specified. Throttling allows you to regulate the performance impact of the
backup operation. Priority can be any number between 1 and 100, with 1
representing the lowest priority, and 100 representing the highest priority.
If the UTIL_IMPACT_PRIORITY keyword is specified with no priority, the
backup will run with the default priority of 50. If
UTIL_IMPACT_PRIORITY is not specified, the backup will run in
unthrottled mode. An impact policy must be defined by setting the
util_impact_lim configuration parameter for a backup to run in throttled
mode.
COMPRESS
Indicates that the backup is to be compressed.
COMPRLIB name
Indicates the name of the library to be used to perform the
compression (e.g., db2compr.dll for Windows; libdb2compr.so for
Linux/UNIX systems). The name must be a fully qualified path
referring to a file on the server. If this parameter is not specified,
the default DB2 compression library will be used. If the specified
library cannot be loaded, the backup will fail.
Examples
Usage notes
The data in a backup cannot be protected by the database server. Make sure that
backups are properly safeguarded, particularly if the backup contains
LBAC-protected data.
When using a variable block size, you must specify a backup buffer size that is less
than or equal to the maximum limit for the tape devices that you are using. For
optimal performance, the buffer size must be equal to the maximum block size
limit of the device being used.
As you regularly backup your database, you might accumulate very large database
backup images, many database logs and load copy images, all of which might be
taking up a large amount of disk space. Refer to “Managing recovery objects” for
information on how to manage these recovery objects.
Command execution status is returned in the SQLCA resulting from the CALL
statement. If execution is successful, the command returns additional information.
The backup operation will return one result set, comprising one row per database
partition that participated in the backup.
Table 26. Result set for a backup operation
Column name Data type Description
BACKUP_TIME VARCHAR(14) Corresponds to the
timestamp string used to
name the backup image.
DBPARTITIONNUM SMALLINT The database partition
number on which the agent
executed the backup
operation.
SQLCODE INTEGER Final SQLCODE resulting
from the backup processing
on the specified database
partition.
SQLERRMC VARCHAR(70) Final SQLERRMC resulting
from the backup processing
on the specified database
partition.
SQLERRML SMALLINT Final SQLERRML resulting
from the backup processing
on the specified database
partition.
Authorization
Required connection
Database
Command syntax
OUTPUT
DESCRIBE select-statement
call-statement
XQUERY XQuery-statement
TABLE table-name
INDEXES FOR TABLE SHOW DETAIL
DATA PARTITIONS FOR TABLE
Command parameters
OUTPUT
Indicates that the output of the statement should be described. This
keyword is optional.
select-statement | call-statement | XQUERY XQuery-statement
Identifies the statement about which information is wanted. The
statement is automatically prepared by CLP. To identify an XQuery
Examples
Describing a table
5 record(s) selected.
0 record(s) selected.
Return Status = 0
1 record(s) selected.
1 record(s) selected
2 record(s) selected.
Return Status = 0
3 record(s) selected.
The following example shows how to describe data partitions with ’SHOW
DETAIL’ clause.
CALL SYSPROC.ADMIN_CMD(’describe data partitions for table part_table2 show detail’)
3 record(s) selected.
Return Status = 0
3 record(s) selected.
Return Status = 0
Usage note
If the DESCRIBE command tries to create a temporary table and fails, creation of
SYSTOOLSTMPSPACE is attempted, and then creation of the temporary table is
attempted again, this time in SYSTOOLSTMPSPACE. SYSCTRL or SYSADM
authority is required to create the SYSTOOLSTMPSPACE table space.
Command execution status is returned in the SQLCA resulting from the CALL
statement. If execution is successful, the commands return additional information
in result sets as follows:
v Table 27: DESCRIBE select-statement, DESCRIBE call-statement and DESCRIBE
XQUERY XQuery-statement commands
v Table 28 on page 55: Result set 1 for the DESCRIBE TABLE command
v Table 29 on page 56: Result set 2 for the DESCRIBE TABLE command
v Table 30 on page 56: DESCRIBE INDEXES FOR TABLE command
v Table 31 on page 57: Result set 1 for the DESCRIBE DATA PARTITIONS FOR
TABLE command
v Table 32 on page 57: Result set 2 for the DESCRIBE DATA PARTITIONS FOR
TABLE command
Table 27. Result set returned by the DESCRIBE select-statement, DESCRIBE call-statement
and DESCRIBE XQUERY XQuery-statement commands
Column name Data type LOB only1 Description
SQLTYPE_ID SMALLINT No Data type of the column, as
it appears in the SQLTYPE
field of the SQL descriptor
area (SQLDA).
SQLTYPE VARCHAR No Data type corresponding to
(257) the SQLTYPE_ID value.
SQLLEN INTEGER No Length attribute of the
column, as it appears in the
SQLLEN field of the SQLDA.
Note: 1: Yes indicates that non-null values are returned only when there is LOB
data being described.
Table 28. Result set 1 returned by the DESCRIBE TABLE command
Column name Data type Detail2 Description
COLNAME VARCHAR No Column name.
(128)
TYPESCHEMA VARCHAR No If the column name is
(128) distinct, the schema name is
returned, otherwise,
’SYSIBM’ is returned.
TYPENAME VARCHAR No Name of the column type.
(128)
FOR_BINARY_DATA CHAR (1) Yes Returns ’Y’ if the column is
of type CHAR, VARCHAR
or LONG VARCHAR, and is
defined as FOR BIT DATA,
’N’ otherwise.
LENGTH INTEGER No Maximum length of the data.
For DECIMAL data, this
indicates the precision. For
discinct types, 0 is returned.
SCALE SMALLINT No For DECIMAL data, this
indicates the scale. For all
other types, 0 is returned.
NULLABLE CHAR (1) No One of:
v ’Y’ if column is nullable
v ’N’ if column is not
nullable
COLNO SMALLINT Yes Ordinal of the column.
PARTKEYSEQ SMALLINT Yes Ordinal of the column within
the table’s partitioning key.
NULL or 0 is returned if the
column is not part of the
partitioning key, and is
NULL for subtables and
hierarchy tables.
Note: 2: Yes indicates that non-null values are returned only when the SHOW
DETAIL clause is used.
Table 29. Result set 2 returned by the DESCRIBE TABLE command when the SHOW
DETAIL clause is used.
Column name Data type Description
DATA_PARTITION_KEY_SEQ INTEGER Data partition key number, for
example, 1 for the first data
partition expression and 2 for the
second data partition expression.
DATA_PARTITION_EXPRESSION CLOB (32K) Expression for this data partition
key in SQL syntax
Table 30. Result set returned by the DESCRIBE INDEXES FOR TABLE command
Column name Data type Detail2 Description
INDSCHEMA VARCHAR No Index schema name.
(128)
INDNAME VARCHAR No Index name.
(128)
UNIQUE_RULE VARCHAR No One of:
(30) v DUPLICATES_ALLOWED
v PRIMARY_INDEX
v
UNIQUE_ENTRIES_ONLY
COLCOUNT SMALLINT No Number of columns in the
key, plus the number of
include columns, if any.
COLNAMES VARCHAR Yes List of the column names,
(2048) each preceded with a + to
indicate ascending order or a
- to indicate descending
order.
Note: 2: Yes indicates that non-null values are returned only when the SHOW
DETAIL clause is used.
Table 32. Result set 2 returned by the DESCRIBE DATA PARTITIONS FOR TABLE
command when the SHOW DETAIL clause is used.
Column name Data type Description
DATA_PARTITION_ID INTEGER Data partition identifier.
DATA_PARTITION_NAME VARCHAR (128) Data partition name.
TBSPID INTEGER Identifier of the table space where
this data partition is stored.
PARTITION_OBJECT_ID INTEGER Identifier of the DMS object where
this data partition is stored.
LONG_TBSPID INTEGER Identifier of the table space where
long data is stored.
ACCESSMODE VARCHAR (20) Defines accessibility of the data
partition and is one of:
v FULL_ACCESS
v NO_ACCESS
v NO_DATA_MOVEMENT
v READ_ONLY
STATUS VARCHAR(64) Data partition status and can be
one of:
v NEWLY_ATTACHED
v NEWLY_DETACHED: MQT
maintenance is required.
v INDEX_CLEANUP_PENDING:
detached data partition whose
tuple in SYSDATAPARTITIONS
is maintained only for index
cleanup. This tuple is removed
when all index records referring
to the detached data partition
have been deleted.
The column is blank otherwise.
Authorization
None
Required connection
Command syntax
Command parameters
CONTACT name
The name of the contact that will be dropped from the local system.
Example
Drop the contact named ’testuser’ from the list of contacts on the server system.
CALL SYSPROC.ADMIN_CMD( ’drop contact testuser’ )
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Authorization
None
Required Connection
Command Syntax
Command Parameters
CONTACTGROUP name
The name of the contact group that will be dropped from the local system.
Example
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Quick link to “File type modifiers for the export utility” on page 65.
Authorization
Required connection
Database. Utility access to Linux, UNIX, or Windows database servers from Linux,
UNIX, or Windows clients must be a direct connection through the engine and not
through a DB2 Connect™ gateway or loop back environment.
Command syntax
LOBS TO lob-path
, ,
XMLSAVESCHEMA ,
METHOD N ( column-name )
MESSAGES ON SERVER
select-statement
XQUERY xquery-statement
HIERARCHY STARTING sub-table-name
traversal-order-list
WHERE
traversal-order-list:
( sub-table-name )
Command parameters
HIERARCHY traversal-order-list
Export a sub-hierarchy using the specified traverse order. All sub-tables
must be listed in PRE-ORDER fashion. The first sub-table name is used as
the target table name for the SELECT statement.
HIERARCHY STARTING sub-table-name
Using the default traverse order (OUTER order for ASC, DEL, or WSF files,
or the order stored in PC/IXF data files), export a sub-hierarchy starting
from sub-table-name.
LOBFILE filename
Specifies one or more base file names for the LOB files. When name space
is exhausted for the first name, the second name is used, and so on. The
maximum number of file names that can be specified is 999. This will
implicitly activate the LOBSINFILE behavior.
When creating LOB files during an export operation, file names are
constructed by appending the current base name from this list to the
current path (from lob-path), and then appending a 3-digit sequence
number and the three character identifier lob. For example, if the current
LOB path is the directory /u/foo/lob/path/, and the current LOB file name
is bar, the LOB files created will be /u/foo/lob/path/bar.001.lob,
/u/foo/lob/path/bar.002.lob, and so on.
LOBS TO lob-path
Specifies one or more paths to directories in which the LOB files are to be
stored. The path(s) must exist on the coordinator partition of the server
and must be fully qualified. There will be at least one file per LOB path,
Example
The following example shows how to export information from the STAFF table in
the SAMPLE database to the file myfile.ixf. The output will be in IXF format. You
must be connected to the SAMPLE database before issuing the command.
CALL SYSPROC.ADMIN_CMD (’EXPORT to /home/user1/data/myfile.ixf
OF ixf MESSAGES ON SERVER select * from staff’)
Usage notes
v Any path used in the EXPORT command must be a valid fully-qualified path on
the server.
v If a table contains LOB columns, at least one fully-qualified LOB path and LOB
name must be specified, using the LOBS TO and LOBFILE clauses.
v The export utility issues a COMMIT statement at the beginning of the operation
which, in the case of Type 2 connections, causes the procedure to return
SQL30090N with reason code 2.
v When exporting from a UCS-2 database to a delimited ASCII (DEL) file, all
character data is converted to the code page that is in effect where the procedure
is executing. Both character string and graphic string data are converted to the
same SBCS or MBCS code page of the server.
But an export command using the same select clause will not:
db2 export to test.del of del select col2 from test
where char(col2)=’05/10/2005’;
Number of rows exported: 0
Now, replacing the LOCALE date format with ISO format gives the expected
results:
db2 export to test.del of del select col2 from test
where char(col2)=’2005-05-10’;
Number of rows exported: 3
Command execution status is returned in the SQLCA resulting from the CALL
statement. If execution is successful, the command returns additional information
in result sets as follows:
Table 33. Result set returned by the EXPORT command
Column name Data type Description
ROWS_EXPORTED BIGINT Total number of exported rows.
MSG_RETRIEVAL VARCHAR(512) SQL statement that is used to retrieve
messages created by this utility. For
example:
SELECT SQLCODE, MSG
FROM TABLE (SYSPROC.ADMIN_GET_MSGS
(’3203498_txu’)) AS MSG
MSG_REMOVAL VARCHAR(512) SQL statement that is used to clean up
messages created by this utility. For
example:
CALL SYSPROC.ADMIN_REMOVE_MSGS
(’3203498_txu’)
Each path contains at least one file that contains at least one LOB pointed to by a
Lob Location Specifier (LLS) in the data file. The LLS is a string representation of
the location of a LOB in a file stored in the LOB file path. The format of an LLS is
filename.ext.nnn.mmm/, where filename.ext is the name of the file that contains the
LOB, nnn is the offset in bytes of the LOB within the file, and mmm is the length
of the LOB in bytes. For example, if the string db2exp.001.123.456/ is stored in
the data file, the LOB is located at offset 123 in the file db2exp.001, and is 456
bytes long.
If you specify the “lobsinfile” modifier when using EXPORT, the LOB data is
placed in the locations specified by the LOBS TO clause. Otherwise the LOB data
is sent to the data file directory. The LOBS TO clause specifies one or more paths
to directories in which the LOB files are to be stored. There will be at least one
file per LOB path, and each file will contain at least one LOB. The LOBS TO or
LOBFILE options will implicitly activate the LOBSINFILE behavior.
To indicate a null LOB , enter the size as -1. If the size is specified as 0, it is
treated as a 0 length LOB. For null LOBS with length of -1, the offset and the file
name are ignored. For example, the LLS of a null LOB might be db2exp.001.7.-1/.
xmlinsepfiles Each XQuery Data Model (XDM) instance is written to a separate file. By default,
multiple values are concatenated together in the same file.
lobsinsepfiles Each LOB value is written to a separate file. By default, multiple values are
concatenated together in the same file.
xmlnodeclaration XDM instances are written without an XML declaration tag. By default, XDM
instances are exported with an XML declaration tag at the beginning that includes
an encoding attribute.
xmlchar XDM instances are written in the character codepage. Note that the character
codepage is the value specified by the codepage file type modifier, or the
application codepage if it is not specified. By default, XDM instances are written
out in Unicode.
xmlgraphic If the xmlgraphic modifier is specified with the EXPORT command, the exported
XML document will be encoded in the UTF-16 code page regardless of the
application code page or the codepage file type modifier.
Table 35. Valid file type modifiers for the export utility: DEL (delimited ASCII) file format
Modifier Description
chardelx x is a single character string delimiter. The default value is a double quotation
mark (″). The specified character is used in place of double quotation marks to
enclose a character string.2 If you want to explicitly specify the double quotation
mark as the character string delimiter, it should be specified as follows:
modified by chardel""
The single quotation mark (’) can also be specified as a character string delimiter
as follows:
modified by chardel’’
For pure DBCS (graphic), mixed DBCS, and EUC, delimiters are restricted to the
range of x00 to x3F, inclusive. The codepage modifier cannot be used with the
lobsinfile modifier.
coldelx x is a single character column delimiter. The default value is a comma (,). The
specified character is used in place of a comma to signal the end of a column.2
In the following example, coldel; causes the export utility to use the semicolon
character (;) as a column delimiter for the exported data:
db2 "export to temp of del modified by coldel;
select * from staff where dept = 20"
decplusblank Plus sign character. Causes positive decimal values to be prefixed with a blank
space instead of a plus sign (+). The default action is to prefix positive decimal
values with a plus sign.
decptx x is a single character substitute for the period as a decimal point character. The
default value is a period (.). The specified character is used in place of a period as
a decimal point character.2
nochardel Column data will not be surrounded by character delimiters. This option should
not be specified if the data is intended to be imported or loaded using DB2. It is
provided to support vendor data files that do not have character delimiters.
Improper usage might result in data loss or corruption.
This option cannot be specified with chardelx or nodoubledel. These are mutually
exclusive options.
nodoubledel Suppresses recognition of double character delimiters.2
striplzeros Removes the leading zeros from all exported decimal columns.
In the first export operation, the content of the exported file data will be
+00000000000000000000000000001.10. In the second operation, which is identical
to the first except for the striplzeros modifier, the content of the exported file
data will be +1.10.
The MMM element will produce the following values: ’Jan’, ’Feb’, ’Mar’, ’Apr’,
’May’, ’Jun’, ’Jul’, ’Aug’, ’Sep’, ’Oct’, ’Nov’, and ’Dec’. ’Jan’ is equal to month 1,
and ’Dec’ is equal to month 12.
For pure DBCS (graphic), mixed DBCS, and EUC, delimiters are restricted to the
range of x00 to x3F, inclusive. The codepage modifier cannot be used with the
lobsinfile modifier.
Table 37. Valid file type modifiers for the export utility: WSF file format
Modifier Description
1 Creates a WSF file that is compatible with Lotus 1-2-3 Release 1, or Lotus 1-2-3
Release 1a.5 This is the default.
2 Creates a WSF file that is compatible with Lotus Symphony Release 1.0.5
3 Creates a WSF file that is compatible with Lotus 1-2-3 Version 2, or Lotus
Symphony Release 1.1.5
4 Creates a WSF file containing DBCS characters.
Note:
1. The export utility does not issue a warning if an attempt is made to use
unsupported file types with the MODIFIED BY option. If this is attempted, the
export operation fails, and an error code is returned.
2. Delimiter considerations for moving data lists restrictions that apply to the
characters that can be used as delimiter overrides.
3. The export utility normally writes
v date data in YYYYMMDD format
v char(date) data in ″YYYY-MM-DD″ format
v time data in ″HH.MM.SS″ format
v time stamp data in ″YYYY-MM-DD-HH. MM.SS.uuuuuu″ format
Data contained in any datetime columns specified in the SELECT statement
for the export operation will also be in these formats.
4. For time stamp formats, care must be taken to avoid ambiguity between the
month and the minute descriptors, since they both use the letter M. A month
field must be adjacent to other date fields. A minute field must be adjacent to
other time fields. Following are some ambiguous time stamp formats:
"M" (could be a month, or a minute)
"M:M" (Which is which?)
"M:YYYY:M" (Both are interpreted as month.)
"S:M:YYYY" (adjacent to both a time value and a date value)
In ambiguous cases, the utility will report an error message, and the operation
will fail.
Following are some unambiguous time stamp formats:
"M:YYYY" (Month)
"S:M" (Minute)
"M:YYYY:S:M" (Month....Minute)
"M:H:YYYY:M:D" (Minute....Month)
5. These files can also be directed to a specific product by specifying an L for
Lotus 1-2-3, or an S for Symphony in the filetype-mod parameter string. Only
one value or product designator can be specified.
.
The LOBSINFILE file type modifier must be specified in order to have LOB
files generated.
11. The export utility appends a numeric identifier to each LOB file or XML file.
The identifier starts as a 3 digit, 0 padded sequence value, starting at
.001
. After the 999th LOB file or XML file, the identifier will no longer be padded
with zeroes (for example, the 1000th LOG file or XML file will have an
extension of
.1000
or
.xml
. For example, a generated LOB file would have a name in the format
myfile.del.001.lob
.
12. It is possible to have the export utility export XDM instances that are not
well-formed documents by specifying an XQuery. However, you will not be
Chapter 3. Supported routines and views 69
able to import or load these exported documents directly into an XML
column, since XML columns can only contain complete documents.
Scope
This command affects all database partitions that are listed in the
$HOME/sqllib/db2nodes.cfg file.
Authorization
Required connection
Database
Command syntax
( application-handle )
Command parameters
FORCE APPLICATION
ALL All applications will be disconnected from the database. This might
close the connection the ADMIN_CMD procedure is running on,
which causes an SQL1224N error to be returned for the
ADMIN_CMD procedure once the force operation is completed
successfully.
application-handle
Specifies the agent to be terminated. List the values using the LIST
APPLICATIONS command.
MODE ASYNC
The command does not wait for all specified users to be terminated before
Examples
The following example forces two users, with application-handle values of 41408 and
55458, to disconnect from the database:
CALL SYSPROC.ADMIN_CMD( ’force application ( 41408, 55458 )’ )
Usage notes
To preserve database integrity, only users who are idling or executing interruptible
database operations can be terminated.
After a FORCE APPLICATION has been issued, the database will still accept
requests to connect. Additional forces might be required to completely force all
users off.
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Authorization
Required connection
Database
Command syntax
USER_PREFERRED_NUMBER CURRENT_NUMBER
--------------------- --------------
2 2
1 record(s) selected.
Return Status = 0
Usage notes
The user preferred self tuning memory manager (STMM) tuning database partition
number (USER_PREFERRED_NUMBER) is set by the user and specifies the
database partition on which the user wishes to run the memory tuner. While the
database is running, the tuning partition is updated asynchronously a few times an
hour. As a result, it is possible that the CURRENT_NUMBER and
USER_PREFERRED_NUMBER returned are not in sync after an update of the user
preferred STMM partition number. To resolve this, either wait for the
CURRENT_NUMBER to be updated asynchronously, or stop and start the database
to force the update of CURRENT_NUMBER.
Command execution status is returned in the SQLCA resulting from the CALL
statement. If execution is successful, the command returns additional information
in the following result set:
Table 38. Result set returned by the GET STMM TUNING DBPARTITIONNUM command
Column name Data type Description
USER_PREFERRED_NUMBER INTEGER User preferred self tuning memory
manager (STMM) tuning database
partition number. A value of -1
indicates that the default database
partition is used.
CURRENT_NUMBER INTEGER Current STMM tuning database
partition number. A value of -1
indicates that the default database
partition is used.
Quick link to “File type modifiers for the import utility” on page 86.
Authorization
v IMPORT using the INSERT option requires one of the following:
– sysadm
Required connection
Database. Utility access to Linux, UNIX, or Windows database servers from Linux,
UNIX, or Windows clients must be a direct connection through the engine and not
through a DB2 Connect gateway or loop back environment.
Command syntax
MODIFIED BY filetype-mod
,
N ( column-name )
,
P ( column-position )
XMLPARSE STRIP WHITESPACE
PRESERVE
ALLOW NO ACCESS
XMLVALIDATE USING XDS Ignore and Map parameters ALLOW WRITE ACCESS
DEFAULT schema-sqlid
SCHEMA schema-sqlid
SCHEMALOCATION HINTS
COMMITCOUNT n RESTARTCOUNT n ROWCOUNT n WARNINGCOUNT n NOTIMEOUT
AUTOMATIC SKIPCOUNT
MESSAGES ON SERVER
( insert-column )
hierarchy description AS ROOT TABLE
UNDER sub-table-name
,
IGNORE ( schema-sqlid )
,
hierarchy description:
ALL TABLES
sub-table-list HIERARCHY STARTING sub-table-name
IN traversal-order-list
sub-table-list:
( sub-table-name )
,
( insert-column )
traversal-order-list:
( sub-table-name )
tblspace-specs:
IN tablespace-name
INDEX IN tablespace-name LONG IN tablespace-name
Command parameters
ALL TABLES
An implicit keyword for hierarchy only. When importing a hierarchy, the
default is to import all tables specified in the traversal order.
ALLOW NO ACCESS
Runs import in the offline mode. An exclusive (X) lock on the target table
is acquired before any rows are inserted. This prevents concurrent
applications from accessing table data. This is the default import behavior.
ALLOW WRITE ACCESS
Runs import in the online mode. An intent exclusive (IX) lock on the target
table is acquired when the first row is inserted. This allows concurrent
readers and writers to access table data. Online mode is not compatible
with the REPLACE, CREATE, or REPLACE_CREATE import options.
Note: If the data was exported from an MVS™ host database, and it
contains LONGVAR fields whose lengths, calculated on the page size, are
more than 254, CREATE might fail because the rows are too long. See
“Imported table re-creation” for a list of restrictions. In this case, the table
should be created manually, and IMPORT with INSERT should be invoked,
or, alternatively, the LOAD command should be used.
Note: Specifying which table space will contain an index can only be done
when the table is created.
insert-column
Specifies the name of a column in the table or the view into which data is
to be inserted.
INSERT
Adds the imported data to the table without changing the existing table
data.
Note: This method can only be used with ASC files, and is the
only valid option for that file type.
N Specifies the names of the columns in the data file to be imported.
The case of these column names must match the case of the
corresponding names in the system catalogs. Each table column
that is not nullable should have a corresponding entry in the
METHOD N list. For example, given data fields F1, F2, F3, F4, F5,
and F6, and table columns C1 INT, C2 INT NOT NULL, C3 INT
NOT NULL, and C4 INT, method N (F2, F1, F4, F3) is a valid
request, while method N (F2, F1) is not valid.
Note: This method can only be used with IXF or DEL files, and is
the only valid option for the DEL file type.
MODIFIED BY filetype-mod
Specifies file type modifier options. See “File type modifiers for the import
utility” on page 86.
NOTIMEOUT
Specifies that the import utility will not time out while waiting for locks.
This option supersedes the locktimeout database configuration parameter.
Other applications are not affected.
NULL INDICATORS null-indicator-list
This option can only be used when the METHOD L parameter is specified.
That is, the input file is an ASC file. The null indicator list is a
comma-separated list of positive integers specifying the column number of
each null indicator field. The column number is the byte offset of the null
indicator field from the beginning of a row of data. There must be one
entry in the null indicator list for each data field defined in the METHOD
L parameter. A column number of zero indicates that the corresponding
data field always contains data.
A value of Y in the NULL indicator column specifies that the column data
is NULL. Any character other than Y in the NULL indicator column
specifies that the column data is not NULL, and that column data specified
by the METHOD L option will be imported.
The NULL indicator character can be changed using the MODIFIED BY
option, with the nullindchar file type modifier.
Example
The following example shows how to import information from the file myfile.ixf to
the STAFF table in the SAMPLE database.
CALL SYSPROC.ADMIN_CMD
(’IMPORT FROM /home/userid/data/myfile.ixf
OF IXF MESSAGES ON SERVER INSERT INTO STAFF’)
Usage notes
Any path used in the IMPORT command must be a valid fully-qualified path on
the coordinator node for the server.
Be sure to complete all table operations and release all locks before starting an
import operation. This can be done by issuing a COMMIT after closing all cursors
opened WITH HOLD, or by issuing a ROLLBACK.
The import utility adds rows to the target table using the SQL INSERT statement.
The utility issues one INSERT statement for each row of data in the input file. If an
INSERT statement fails, one of two actions result:
v If it is likely that subsequent INSERT statements can be successful, a warning
message is written to the message file, and processing continues.
v If it is likely that subsequent INSERT statements will fail, and there is potential
for database damage, an error message is written to the message file, and
processing halts.
The utility performs an automatic COMMIT after the old rows are deleted during a
REPLACE or a REPLACE_CREATE operation. Therefore, if the system fails, or the
application interrupts the database manager after the table object is truncated, all
of the old data is lost. Ensure that the old data is no longer needed before using
these options.
By default, automatic COMMITs are not performed for the INSERT or the
INSERT_UPDATE option. They are, however, performed if the COMMITCOUNT
parameter is not zero. If automatic COMMITs are not performed, a full log results
in a ROLLBACK.
Offline import does not perform automatic COMMITs if any of the following
conditions is true:
v the target is a view, not a table
v compound inserts are used
v buffered inserts are used
By default, online import performs automatic COMMITs to free both the active log
space and the lock list. Automatic COMMITs are not performed only if a
COMMITCOUNT value of zero is specified.
Whenever the import utility performs a COMMIT, two messages are written to the
message file: one indicates the number of records to be committed, and the other is
written after a successful COMMIT. When restarting the import operation after a
failure, specify the number of records to skip, as determined from the last
successful COMMIT.
If an error occurs while recreating the foreign keys, modify the data to maintain
referential integrity.
Referential constraints and foreign key definitions are not preserved when
recreating tables from PC/IXF files. (Primary key definitions are preserved if the
data was previously exported using SELECT *.)
Importing to a remote database requires enough disk space on the server for a
copy of the input data file, the output message file, and potential growth in the
size of the database.
If an import operation is run against a remote database, and the output message
file is very long (more than 60 KB), the message file returned to the user on the
client might be missing messages from the middle of the import operation. The
first 30 KB of message information and the last 30 KB of message information are
always retained.
Importing PC/IXF files to a remote database is much faster if the PC/IXF file is on
a hard drive rather than on diskettes.
The database table or hierarchy must exist before data in the ASC, DEL, or WSF
file formats can be imported; however, if the table does not already exist, IMPORT
CREATE or IMPORT REPLACE_CREATE creates the table when it imports data
from a PC/IXF file. For typed tables, IMPORT CREATE can create the type
hierarchy and the table hierarchy as well.
PC/IXF import should be used to move data (including hierarchical data) between
databases. If character data containing row separators is exported to a delimited
ASCII (DEL) file and processed by a text transfer program, fields containing the
row separators will shrink or expand. The file copying step is not necessary if the
source and the target databases are both accessible from the same client.
The data in ASC and DEL files is assumed to be in the code page of the client
application performing the import. PC/IXF files, which allow for different code
pages, are recommended when importing data in different code pages. If the
PC/IXF file and the import utility are in the same code page, processing occurs as
for a regular application. If the two differ, and the FORCEIN option is specified,
the import utility assumes that data in the PC/IXF file has the same code page as
the application performing the import. This occurs even if there is a conversion
table for the two code pages. If the two differ, the FORCEIN option is not
specified, and there is a conversion table, all data in the PC/IXF file will be
converted from the file code page to the application code page. If the two differ,
For table objects on an 8 KB page that are close to the limit of 1012 columns,
import of PC/IXF data files might cause DB2 to return an error, because the
maximum size of an SQL statement was exceeded. This situation can occur only if
the columns are of type CHAR, VARCHAR, or CLOB. The restriction does not
apply to import of DEL or ASC files. If PC/IXF files are being used to create a
new table, an alternative is use db2look to dump the DDL statement that created
the table, and then to issue that statement through the CLP.
DB2 Connect can be used to import data to DRDA servers such as DB2 for
OS/390, DB2 for VM and VSE, and DB2 for OS/400. Only PC/IXF import (INSERT
option) is supported. The RESTARTCOUNT parameter, but not the
COMMITCOUNT parameter, is also supported.
When using the CREATE option with typed tables, create every sub-table defined
in the PC/IXF file; sub-table definitions cannot be altered. When using options
other than CREATE with typed tables, the traversal order list enables one to
specify the traverse order; therefore, the traversal order list must match the one
used during the export operation. For the PC/IXF file format, one need only
specify the target sub-table name, and use the traverse order stored in the file.
The import utility can be used to recover a table previously exported to a PC/IXF
file. The table returns to the state it was in when exported.
Importing a multiple-part PC/IXF file whose individual parts are copied from a
Windows system to an AIX system is supported. Only the name of the first file
must be specified in the IMPORT command. For example, IMPORT FROM data.ixf
OF IXF INSERT INTO TABLE1. The file data.002, etc should be available in the same
directory as data.ixf.
Security labels in their internal format might contain newline characters. If you
import the file using the DEL file format, those newline characters can be mistaken
for delimiters. If you have this problem use the older default priority for delimiters
by specifying the delprioritychar file type modifier in the IMPORT command.
Federated considerations
Command execution status is returned in the SQLCA resulting from the CALL
statement. If execution is successful, the command returns additional information
in result sets as follows:
Table 39. Result set returned by the IMPORT command
Column name Data type Description
ROWS_READ BIGINT Number of records read from the file during
import.
ROWS_SKIPPED BIGINT Number of records skipped before inserting
or updating begins.
ROWS_INSERTED BIGINT Number of rows inserted into the target
table.
ROWS_UPDATED BIGINT Number of rows in the target table updated
with information from the imported records
(records whose primary key value already
exists in the table).
ROWS_REJECTED BIGINT Number of records that could not be
imported.
ROWS_COMMITTED BIGINT Number of records imported successfully
and committed to the database.
MSG_RETRIEVAL VARCHAR(512) SQL statement that is used to retrieve
messages created by this utility. For
example:
SELECT SQLCODE, MSG
FROM TABLE (SYSPROC.ADMIN_GET_MSGS
(’1203498_txu’)) AS MSG
MSG_REMOVAL VARCHAR(512) SQL statement that is used to clean up
messages created by this utility. For
example:
CALL SYSPROC.ADMIN_REMOVE_MSGS
(’1203498_txu’)
If this modifier is specified, and the transaction log is not sufficiently large, the
import operation will fail. The transaction log must be large enough to
accommodate either the number of rows specified by COMMITCOUNT, or the
number of rows in the data file if COMMITCOUNT is not specified. It is therefore
recommended that the COMMITCOUNT option be specified to avoid transaction
log overflow.
Each path contains at least one file that contains at least one LOB pointed to by a
Lob Location Specifier (LLS) in the data file. The LLS is a string representation of
the location of a LOB in a file stored in the LOB file path. The format of an LLS is
filename.ext.nnn.mmm/, where filename.ext is the name of the file that contains the
LOB, nnn is the offset in bytes of the LOB within the file, and mmm is the length
of the LOB in bytes. For example, if the string db2exp.001.123.456/ is stored in
the data file, the LOB is located at offset 123 in the file db2exp.001, and is 456
bytes long.
The LOBS FROM clause specifies where the LOB files are located when the
“lobsinfile” modifier is used. The LOBS FROM clause will implicitly activate the
LOBSINFILE behavior. The LOBS FROM clause conveys to the IMPORT utility
the list of paths to search for the LOB files while importing the data.
To indicate a null LOB, enter the size as -1. If the size is specified as 0, it is
treated as a 0 length LOB. For null LOBS with length of -1, the offset and the file
name are ignored. For example, the LLS of a null LOB might be db2exp.001.7.-1/.
no_type_id Valid only when importing into a single sub-table. Typical usage is to export data
from a regular table, and then to invoke an import operation (using this modifier)
to convert the data into a single sub-table.
nodefaults If a source column for a target table column is not explicitly specified, and the
table column is not nullable, default values are not loaded. Without this option, if
a source column for one of the target table columns is not explicitly specified, one
of the following occurs:
v If a default value can be specified for a column, the default value is loaded
v If the column is nullable, and a default value cannot be specified for that
column, a NULL is loaded
v If the column is not nullable, and a default value cannot be specified, an error
is returned, and the utility stops processing.
norowwarnings Suppresses all warnings about rejected rows.
A default value of 1 is assigned for each element that is not specified. Some
examples of date formats are:
"D-M-YYYY"
"MM.DD.YYYY"
"YYYYDDD"
implieddecimal The location of an implied decimal point is determined by the column definition;
it is no longer assumed to be at the end of the value. For example, the value
12345 is loaded into a DECIMAL(8,2) column as 123.45, not 12345.00.
A default value of 0 is assigned for each element that is not specified. Some
examples of time formats are:
"HH:MM:SS"
"HH.MM TT"
"SSSSS"
The valid values for the MMM element include: ’jan’, ’feb’, ’mar’, ’apr’, ’may’,
’jun’, ’jul’, ’aug’, ’sep’, ’oct’, ’nov’ and ’dec’. These values are case insensitive.
The following example illustrates how to import data containing user defined
date and time formats into a table called schedule:
db2 import from delfile2 of del
modified by timestampformat="yyyy.mm.dd hh:mm tt"
insert into schedule
This modifier should be used in conjunction with the delimited data file
generated by drop table recovery only if the table being recovered has graphic
data.
Restrictions
The usegraphiccodepage modifier MUST NOT be specified with DEL files created
by the EXPORT utility, as these files contain data encoded in only one code page.
The usegraphiccodepage modifier is also ignored by the double-byte character
large objects (DBCLOBs) in files.
xmlchar Specifies that XML documents are encoded in the character code page.
This option is useful for processing XML documents that are encoded in the
specified character code page but do not contain an encoding declaration.
For each document, if a declaration tag exists and contains an encoding attribute,
the encoding must match the character code page, otherwise the row containing
the document will be rejected. Note that the character codepage is the value
specified by the codepage file type modifier, or the application codepage if it is
not specified. By default, either the documents are encoded in Unicode, or they
contain a declaration tag with an encoding attribute.
xmlgraphic Specifies that XML documents are encoded in the specified graphic code page.
This option is useful for processing XML documents that are encoded in a specific
graphic code page but do not contain an encoding declaration.
For each document, if a declaration tag exists and contains an encoding attribute,
the encoding must match the graphic code page, otherwise the row containing
the document will be rejected. Note that the graphic code page is the graphic
component of the value specified by the codepage file type modifier, or the
graphic component of the application code page if it is not specified. By default,
documents are either encoded in Unicode, or they contain a declaration tag with
an encoding attribute.
Note: If the xmlgraphic modifier is specified with the IMPORT command, the
XML document to be imported must be encoded in the UTF-16 code page.
Otherwise, the XML document may be rejected with a parsing error, or it may be
imported into the table with data corruption.
Table 42. Valid file type modifiers for the import utility: ASC (non-delimited ASCII) file format
Modifier Description
nochecklengths If nochecklengths is specified, an attempt is made to import each row, even if the
source data has a column definition that exceeds the size of the target table
column. Such rows can be successfully imported if code page conversion causes
the source data to shrink; for example, 4-byte EUC data in the source could
shrink to 2-byte DBCS data in the target, and require half the space. This option
is particularly useful if it is known that the source data will fit in all cases despite
mismatched column definitions.
This modifier is case sensitive for EBCDIC data files, except when the character is
an English letter. For example, if the null indicator character is specified to be the
letter N, then n is also recognized as a null indicator.
reclen=x x is an integer with a maximum value of 32 767. x characters are read for each
row, and a new-line character is not used to indicate the end of the row.
striptblanks Truncates any trailing blank spaces when loading data into a variable-length field.
If this option is not specified, blank spaces are kept.
This option cannot be specified together with striptnulls. These are mutually
exclusive options. This option replaces the obsolete t option, which is supported
for earlier compatibility only.
striptnulls Truncates any trailing NULLs (0x00 characters) when loading data into a
variable-length field. If this option is not specified, NULLs are kept.
This option cannot be specified together with striptblanks. These are mutually
exclusive options. This option replaces the obsolete padwithzero option, which is
supported for earlier compatibility only.
Table 43. Valid file type modifiers for the import utility: DEL (delimited ASCII) file format
Modifier Description
chardelx x is a single character string delimiter. The default value is a double quotation
mark (″). The specified character is used in place of double quotation marks to
enclose a character string.34 If you want to explicitly specify the double quotation
mark as the character string delimiter, it should be specified as follows:
modified by chardel""
The single quotation mark (’) can also be specified as a character string delimiter.
In the following example, chardel’’ causes the import utility to interpret any
single quotation mark (’) it encounters as a character string delimiter:
db2 "import from myfile.del of del
modified by chardel’’
method p (1, 4) insert into staff (id, years)"
coldelx x is a single character column delimiter. The default value is a comma (,). The
specified character is used in place of a comma to signal the end of a column.34
In the following example, coldel; causes the import utility to interpret any
semicolon (;) it encounters as a column delimiter:
db2 import from myfile.del of del
modified by coldel;
messages msgs.txt insert into staff
decplusblank Plus sign character. Causes positive decimal values to be prefixed with a blank
space instead of a plus sign (+). The default action is to prefix positive decimal
values with a plus sign.
In the following example, decpt; causes the import utility to interpret any
semicolon (;) it encounters as a decimal point:
db2 "import from myfile.del of del
modified by chardel’’
decpt; messages msgs.txt insert into staff"
delprioritychar The current default priority for delimiters is: record delimiter, character delimiter,
column delimiter. This modifier protects existing applications that depend on the
older priority by reverting the delimiter priorities to: character delimiter, record
delimiter, column delimiter. Syntax:
db2 import ... modified by delprioritychar ...
With the delprioritychar modifier specified, there will be only two rows in this
data file. The second <row delimiter> will be interpreted as part of the first data
column of the second row, while the first and the third <row delimiter> are
interpreted as actual record delimiters. If this modifier is not specified, there will
be three rows in this data file, each delimited by a <row delimiter>.
keepblanks Preserves the leading and trailing blanks in each field of type CHAR, VARCHAR,
LONG VARCHAR, or CLOB. Without this option, all leading and trailing blanks
that are not inside character delimiters are removed, and a NULL is inserted into
the table for all blank fields.
nochardel The import utility will assume all bytes found between the column delimiters to
be part of the column’s data. Character delimiters will be parsed as part of
column data. This option should not be specified if the data was exported using
DB2 (unless nochardel was specified at export time). It is provided to support
vendor data files that do not have character delimiters. Improper usage might
result in data loss or corruption.
Table 44. Valid file type modifiers for the import utility: IXF file format
Modifier Description
forcein Directs the utility to accept data despite code page mismatches, and to suppress
translation between code pages.
Fixed length target fields are checked to verify that they are large enough for the
data. If nochecklengths is specified, no checking is done, and an attempt is made
to import each row.
indexixf Directs the utility to drop all indexes currently defined on the existing table, and
to create new ones from the index definitions in the PC/IXF file. This option can
only be used when the contents of a table are being replaced. It cannot be used
with a view, or when a insert-column is specified.
Note:
1. The import utility does not issue a warning if an attempt is made to use
unsupported file types with the MODIFIED BY option. If this is attempted, the
import operation fails, and an error code is returned.
2. Double quotation marks around the date format string are mandatory. Field
separators cannot contain any of the following: a-z, A-Z, and 0-9. The field
separator should not be the same as the character delimiter or field delimiter
in the DEL file format. A field separator is optional if the start and end
In ambiguous cases, the utility will report an error message, and the operation
will fail.
Following are some unambiguous time stamp formats:
"M:YYYY" (Month)
"S:M" (Minute)
"M:YYYY:S:M" (Month....Minute)
"M:H:YYYY:M:D" (Minute....Month)
Some characters, such as double quotation marks and back slashes, must be
preceded by an escape character (for example, \).
3. Character values provided for the chardel, coldel, or decpt file type modifiers
must be specified in the code page of the source data.
The character code point (instead of the character symbol), can be specified
using the syntax xJJ or 0xJJ, where JJ is the hexadecimal representation of the
code point. For example, to specify the # character as a column delimiter, use
one of the following:
... modified by coldel# ...
... modified by coldel0x23 ...
... modified by coldelX23 ...
4. Delimiter considerations for moving data lists restrictions that apply to the
characters that can be used as delimiter overrides.
5. The following file type modifiers are not allowed when importing into a
nickname:
v indexixf
v indexschema
v dldelfiletype
v nodefaults
v usedefaults
v no_type_idfiletype
v generatedignore
v generatedmissing
v identityignore
v identitymissing
v lobsinfile
6. The WSF file format is not supported for XML columns.
7. The CREATE mode is not supported for XML columns.
8. All XML data must reside in XML files that are separate from the main data
file. An XML Data Specifier (XDS) (or a NULL value) must exist for each XML
column in the main data file.
Authorization
Required connection
Database
Command syntax
INITIALIZE TAPE
ON device USING blksize
Command parameters
ON device
Specifies a valid tape device name. The default value is \\.\TAPE0. The
device specified must be relative to the server.
USING blksize
Specifies the block size for the device, in bytes. The device is initialized to
use the block size specified, if the value is within the supported range of
block sizes for the device.
The buffer size specified for the BACKUP DATABASE command and for
RESTORE DATABASE must be divisible by the block size specified here.
If a value for this parameter is not specified, the device is initialized to use
its default block size. If a value of zero is specified, the device is initialized
Example
Initialize the tape device to use a block size of 2048 bytes, if the value is within the
supported range of block sizes for the device.
CALL SYSPROC.ADMIN_CMD( ’initialize tape using 2048’ )
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Quick link to “File type modifiers for the load utility” on page 121.
Restrictions
The load utility does not support loading data at the hierarchy level. The load
utility is not compatible with range-clustered tables.
Scope
Authorization
Since all load processes (and all DB2 server processes, in general) are owned by the
instance owner, and all of these processes use the identification of the instance
owner to access needed files, the instance owner must have read access to input
data files. These input data files must be readable by the instance owner, regardless
of who invokes the command.
Required connection
Database.
Command syntax
,
N ( column-name )
,
P ( column-position )
XMLPARSE STRIP WHITESPACE
PRESERVE
XMLVALIDATE USING XDS Ignore and Map parameters SAVECOUNT n
DEFAULT schema-sqlid
SCHEMA schema-sqlid
SCHEMALOCATION HINTS
ROWCOUNT n WARNINGCOUNT n MESSAGES ON SERVER TEMPFILES PATH temp-pathname
, STATISTICS USE PROFILE
(1) (2) NO
FOR EXCEPTION table-name
NORANGEEXC
NOUNIQUEEXC
WITHOUT PROMPTING
NO
COPY YES USE TSM
OPEN num-sess SESSIONS
,
TO device/directory
LOAD lib-name
OPEN num-sess SESSIONS
NONRECOVERABLE
DATA BUFFER buffer-size SORT BUFFER buffer-size CPU_PARALLELISM n DISK_PARALLELISM n
YES INDEXING MODE AUTOSELECT
FETCH_PARALLELISM NO REBUILD
INCREMENTAL
DEFERRED
ALLOW NO ACCESS
ALLOW READ ACCESS SET INTEGRITY PENDING CASCADE IMMEDIATE
USE tablespace-name DEFERRED
LOCK WITH FORCE SOURCEUSEREXIT executable Redirect Input/Output parameters
PARALLELIZE
PARTITIONED DB CONFIG
partitioned-db-option
,
IGNORE ( schema-sqlid )
,
Notes:
1 These keywords can appear in any order.
2 Each of these keywords can only appear once.
Command parameters
FROM filename | pipename | device(query-statement) | (DATABASE database-alias
query-statement)
Specifies the file, pipe or device referring to an SQL statement that contains
the data being loaded, or the SQL statement itself and the optional source
database to load from cursor.
The query-statement option is used to LOAD from a cursor. It contains only
one query statement, which is enclosed in parentheses, and can start with
VALUES, SELECT or WITH. For example,
LOAD FROM (SELECT * FROM T1) OF CURSOR INSERT INTO T2
When the DATABASE database-alias clause is included prior to the query
statement in the parentheses, the LOAD command will attempt to load the
data using the query-statement from the given database as indicated by the
database-alias name, which is defined on the server. It must point to a
database exist on the server, and is a different database that the application
is currently connected to. Note that the LOAD will be executed using the
user ID and password explicitly provided for the currently connected
database (an implicit connection will cause the LOAD to fail).
If the input source is a file, pipe, or device, it must be accessible from the
coordinator partition on the server.
If several names are specified, they will be processed in sequence. If the
last item specified is a tape device and the user is prompted for a tape, the
LOAD will fail and the ADMIN_CMD procedure will return an error.
Note:
Note:
The IGNORE clause applies only to the XDS. A schema that is mapped by
the MAP clause will not be subsequently ignored if specified by the
IGNORE clause.
DEFAULT schema-sqlid
This option can only be used when the USING XDS parameter is specified.
The schema specified through the DEFAULT clause identifies a schema to
use for validation when the XML Data Specifier (XDS) of a loaded XML
document does not contain an SCH attribute identifying an XML Schema.
The DEFAULT clause takes precedence over the IGNORE and MAP
clauses. If an XDS satisfies the DEFAULT clause, the IGNORE and MAP
specifications will be ignored.
MAP schema-sqlid
This option can only be used when the USING XDS parameter is specified.
Use the MAP clause to specify alternate schemas to use in place of those
specified by the SCH attribute of an XML Data Specifier (XDS) for each
loaded XML document. The MAP clause specifies a list of one or more
schema pairs, where each pair represents a mapping of one schema to
another. The first schema in the pair represents a schema that is referred to
by an SCH attribute in an XDS. The second schema in the pair represents
the schema that should be used to perform schema validation.
Note:
1. If this parameter is used with tables containing either LOB or LONG
VARCHAR fields, its value becomes one, regardless of the number of
system CPUs or the value specified by the user.
2. Specifying a small value for the SAVECOUNT parameter causes the
loader to perform many more I/O operations to flush both data and
table metadata. When CPU_PARALLELISM is greater than one, the
flushing operations are asynchronous, permitting the loader to exploit
the CPU. When CPU_PARALLELISM is set to one, the loader waits on
I/O during consistency points. A load operation with
CPU_PARALLELISM set to two, and SAVECOUNT set to 10 000,
completes faster than the same operation with CPU_PARALLELISM set
to one, even though there is only one CPU.
DISK_PARALLELISM n
Specifies the number of processes or threads that the load utility will create
for writing data to the table space containers. If a value is not specified, the
utility selects an intelligent default based on the number of table space
containers and the characteristics of the table.
FETCH_PARALLELISM YES | NO
When performing a load from a cursor where the cursor is declared using
the DATABASE keyword, or when using the API sqlu_remotefetch_entry
media entry, and this option is set to YES, the load utility attempts to
parallelize fetching from the remote data source if possible. If set to NO,
For more information, see Moving data using a customized application (user
exit).
PARTITIONED DB CONFIG partitioned-db-option
Allows you to execute a load into a table distributed across multiple
database partitions. The PARTITIONED DB CONFIG parameter allows you
to specify partitioned database-specific configuration options. The
partitioned-db-option values can be any of the following:
Example
Issue a load with replace option for the employee table data from a file.
CALL SYSPROC.ADMIN_CMD(’LOAD FROM /home/theresax/tmp/emp_exp.dat
OF DEL METHOD P (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
MESSAGES /home/theresax/tmp/emp_load.msg
REPLACE INTO THERESAX.EMPLOYEE (EMPNO, FIRSTNME, MIDINIT, LASTNAME,
WORKDEPT, PHONENO, HIREDATE, JOB, EDLEVEL, SEX, BIRTHDATE, SALARY,
BONUS, COMM) COPY NO INDEXING MODE AUTOSELECT ISOLATE_PART_ERRS
LOAD_ERRS_ONLY MODE PARTITION_AND_LOAD’ )
Return Status = 0
1 record(s) selected.
Note: The following columns are also returned in this result set, but are set to
NULL because they are only populated when loading into a single-partition
database: ROWS_SKIPPED, ROWS_LOADED, ROWS_DELETED and
ROWS_COMMITTED.
1 record(s) selected.
Return Status = 0
Example 1
The user has constructed a data file with XDS fields to describe the documents that
are to be inserted into the table. It might appear like this :
1, "<XDS FIL=""file1.xml"" />"
2, "<XDS FIL=’file2.xml’ OFF=’23’ LEN=’45’ />"
Example 2
The user issues a load command without any parsing or validation options for the
XML column, and the data is loaded successfully:
Loading data from cursor is the same as with a regular relational column type. The
user has two tables, T1 and T2, each of which consist of a single XML column
named C1. To LOAD from T1 into T2, the user will first declare a cursor:
Next, the user may issue a LOAD using the cursor type :
Applying the XML specific LOAD options to the cursor type is the same as loading
from a file.
Usage notes
v Data is loaded in the sequence that appears in the input file. If a particular
sequence is desired, the data should be sorted before a load is attempted. If
preservation of the source data order is not required, consider using the
ANYORDER file type modifier, described below in the File type modifiers for the
load utility section.
v The load utility builds indexes based on existing definitions. The exception
tables are used to handle duplicates on unique keys. The utility does not enforce
referential integrity, perform constraints checking, or update materialized query
tables that are dependent on the tables being loaded. Tables that include
referential or check constraints are placed in Set Integrity Pending state.
Summary tables that are defined with REFRESH IMMEDIATE, and that are
dependent on tables being loaded, are also placed in Set Integrity Pending state.
Issue the SET INTEGRITY statement to take the tables out of Set Integrity
Pending state. Load operations cannot be carried out on replicated materialized
query tables.
v If a clustering index exists on the table, the data should be sorted on the
clustering index prior to loading. Data does not need to be sorted prior to
loading into a multidimensional clustering (MDC) table, however.
v If you specify an exception table when loading into a protected table, any rows
that are protected by invalid security labels will be sent to that table. This might
allow users that have access to the exception table to access to data that they
would not normally be authorized to access. For better security be careful who
you grant exception table access to, delete each row as soon as it is repaired and
copied to the table being loaded, and drop the exception table as soon as you
are done with it.
LOAD RESTART truncates a table up to the last consistency point reached. As part
of LOAD RESTART processing, a compression dictionary will exist in the table if it
was present in the table at the time the last LOAD consistency point was taken. In
that case, LOAD RESTART will not create a new dictionary. For a summary of the
possible conditions, see Table 4 below.
Command execution status is returned in the SQLCA resulting from the CALL
statement. If execution is successful, the command returns additional information.
A single-partition database will return one result set; a multi-partition database
will return two result sets.
v Table 50: Result set for a load operation.
v Table 51 on page 120: Result set 2 contains information for each database
partition in a multi-partition load operation.
Table 50. Result set returned by the LOAD command
Column name Data type Description
ROWS_READ BIGINT Number of rows read during the
load operation.
ROWS_SKIPPED BIGINT Number of rows skipped before the
load operation started. This
information is returned for a
single-partition database only.
ROWS_LOADED BIGINT Number of rows loaded into the
target table. This information is
returned for a single-partition
database only.
ROWS_REJECTED BIGINT Number of rows that could not be
loaded into the target table.
ROWS_DELETED BIGINT Number of duplicate rows that
were not loaded into the target
table. This information is returned
for a single-partition database only.
ROWS_COMMITTED BIGINT Total number of rows processed:
the number of rows successfully
loaded into the target table, plus
the number of skipped and rejected
rows. This information is returned
for a single-partition database only.
ROWS_PARTITIONED BIGINT Number of rows distributed by all
database distributing agents. This
information is returned for a
multi-partition database only.
Table 51. Result set 2 returned by the LOAD command for each database partition in a
multi-partition database.
Column name Data type Description
DBPARTITIONNUM SMALLINT The database partition number on
which the agent executed the load
operation.
SQLCODE INTEGER Final SQLCODE resulting from the
load processing.
To take the table out of Set Integrity Pending state and force verification of the
user-supplied values, issue the following command after the load operation:
SET INTEGRITY FOR < table-name > IMMEDIATE CHECKED.
When this modifier is specified and there is a generated column in any of the
partitioning keys, dimension keys or distribution keys, then the LOAD command
will automatically convert the modifier to generatedignore and proceed with the
load. This will have the effect of regenerating all of the generated column values.
This value takes precedence over the PCTFREE value specified in the CREATE
INDEX statement. The indexfreespace option affects index leaf pages only.
lobsinfile lob-path specifies the path to the files containing LOB data. The ASC, DEL, or IXF
load input files contain the names of the files having LOB data in the LOB
column.
The LOBS FROM clause specifies where the LOB files are located when the
“lobsinfile” modifier is used. The LOBS FROM clause will implicitly activate the
LOBSINFILE behavior. The LOBS FROM clause conveys to the LOAD utility the
list of paths to search for the LOB files while loading the data.
Each path contains at least one file that contains at least one LOB pointed to by a
Lob Location Specifier (LLS) in the data file. The LLS is a string representation of
the location of a LOB in a file stored in the LOB file path. The format of an LLS is
filename.ext.nnn.mmm/, where filename.ext is the name of the file that contains the
LOB, nnn is the offset in bytes of the LOB within the file, and mmm is the length
of the LOB in bytes. For example, if the string db2exp.001.123.456/ is stored in
the data file, the LOB is located at offset 123 in the file db2exp.001, and is 456
bytes long.
To indicate a null LOB , enter the size as -1. If the size is specified as 0, it is
treated as a 0 length LOB. For null LOBS with length of -1, the offset and the file
name are ignored. For example, the LLS of a null LOB might be db2exp.001.7.-1/.
noheader Skips the header verification code (applicable only to load operations into tables
that reside in a single-partition database partition group).
If you have a table consisting of a single DB2SECURITYLABEL column, the data file
might look like this:
"CONFIDENTIAL:ALPHA:G2"
"CONFIDENTIAL;SIGMA:G2"
"TOP SECRET:ALPHA:G2"
To load or import this data, the SECLABELCHAR file type modifier must be
used:
LOAD FROM input.del OF DEL MODIFIED BY SECLABELCHAR INSERT INTO t1
If you have a table consisting of a single DB2SECURITYLABEL column, the data file
might consist of security label names similar to:
"LABEL1"
"LABEL1"
"LABEL2"
To load or import this data, the SECLABELNAME file type modifier must be used:
LOAD FROM input.del OF DEL MODIFIED BY SECLABELNAME INSERT INTO t1
Note: If the file type is ASC, any spaces following the name of the security label
will be interpreted as being part of the name. To avoid this use the striptblanks
file type modifier to make sure the spaces are removed.
totalfreespace=x x is an integer greater than or equal to 0 . The value is interpreted as the
percentage of the total pages in the table that is to be appended to the end of the
table as free space. For example, if x is 20, and the table has 100 data pages after
the data has been loaded, 20 additional empty pages will be appended. The total
number of data pages for the table will be 120. The data pages total does not
factor in the number of index pages in the table. This option does not affect the
index object. If two loads are done with this option specified, the second load will
not reuse the extra space appended to the end by the first load.
usedefaults If a source column for a target table column has been specified, but it contains no
data for one or more row instances, default values are loaded. Examples of
missing data are:
v For DEL files: two adjacent column delimiters (″,,″) or two adjacent column
delimiters separated by an arbitrary number of spaces (″, ,″) are specified for a
column value.
v For DEL/ASC/WSF files: A row that does not have enough columns, or is not
long enough for the original specification. For ASC files, NULL column values
are not considered explicitly missing, and a default will not be substituted for
NULL column values. NULL column values are represented by all space
characters for numeric, date, time, and /timestamp columns, or by using the
NULL INDICATOR for a column of any type to indicate the column is NULL.
Without this option, if a source column contains no data for a row instance, one
of the following occurs:
v For DEL/ASC/WSF files: If the column is nullable, a NULL is loaded. If the
column is not nullable, the utility rejects the row.
A default value of 1 is assigned for each element that is not specified. Some
examples of date formats are:
"D-M-YYYY"
"MM.DD.YYYY"
"YYYYDDD"
dumpfile = x x is the fully qualified (according to the server database partition) name of an
exception file to which rejected rows are written. A maximum of 32 KB of data is
written per record. Following is an example that shows how to specify a dump
file:
db2 load from data of del
modified by dumpfile = /u/user/filename
insert into table_name
The file will be created and owned by the instance owner. To override the default
file permissions, use the dumpfileaccessall file type modifier.
Note:
1. In a partitioned database environment, the path should be local to the loading
database partition, so that concurrently running load operations do not
attempt to write to the same file.
2. The contents of the file are written to disk in an asynchronous buffered mode.
In the event of a failed or an interrupted load operation, the number of
records committed to disk cannot be known with certainty, and consistency
cannot be guaranteed after a LOAD RESTART. The file can only be assumed
to be complete for a load operation that starts and completes in a single pass.
3. If the specified file already exists, it will not be recreated, but it will be
appended.
If the specified file already exists, its permissions will not be changed.
fastparse Use with caution. Reduces syntax checking on user-supplied column values, and
enhances performance. Tables are guaranteed to be architecturally correct (the
utility performs sufficient data checking to prevent a segmentation violation or
trap), however, the coherence of the data is not validated. Only use this option if
you are certain that your data is coherent and correct. For example, if the
user-supplied data contains an invalid timestamp column value of
:1>0-00-20-07.11.12.000000, this value is inserted into the table if FASTPARSE is
specified, and rejected if FASTPARSE is not specified.
implieddecimal The location of an implied decimal point is determined by the column definition;
it is no longer assumed to be at the end of the value. For example, the value
12345 is loaded into a DECIMAL(8,2) column as 123.45, not 12345.00.
A default value of 0 is assigned for each element that is not specified. Some
examples of time formats are:
"HH:MM:SS"
"HH.MM TT"
"SSSSS"
The valid values for the MMM element include: ’jan’, ’feb’, ’mar’, ’apr’, ’may’,
’jun’, ’jul’, ’aug’, ’sep’, ’oct’, ’nov’ and ’dec’. These values are case insensitive.
If the TIMESTAMPFORMAT modifier is not specified, the load utility formats the
timestamp field using one of two possible formats:
YYYY-MM-DD-HH.MM.SS
YYYY-MM-DD HH:MM:SS
The load utility chooses the format by looking at the separator between the DD
and HH. If it is a dash ’-’, the load utility uses the regular dashes and dots format
(YYYY-MM-DD-HH.MM.SS). If it is a blank space, then the load utility expects a
colon ’:’ to separate the HH, MM and SS.
In either format, if you include the microseconds field (UUUUUU), the load
utility expects the dot ’.’ as the separator. Either YYYY-MM-DD-
HH.MM.SS.UUUUUU or YYYY-MM-DD HH:MM:SS.UUUUUU are acceptable.
The following example illustrates how to load data containing user defined date
and time formats into a table called schedule:
db2 load from delfile2 of del
modified by timestampformat="yyyy.mm.dd hh:mm tt"
insert into schedule
usegraphiccodepage If usegraphiccodepage is given, the assumption is made that data being loaded
into graphic or double-byte character large object (DBCLOB) data field(s) is in the
graphic code page. The rest of the data is assumed to be in the character code
page. The graphic codepage is associated with the character code page. LOAD
determines the character code page through either the codepage modifier, if it is
specified, or through the code page of the database if the codepage modifier is not
specified.
This modifier should be used in conjunction with the delimited data file
generated by drop table recovery only if the table being recovered has graphic
data.
Restrictions
The usegraphiccodepage modifier MUST NOT be specified with DEL files created
by the EXPORT utility, as these files contain data encoded in only one code page.
The usegraphiccodepage modifier is also ignored by the double-byte character
large objects (DBCLOBs) in files.
xmlchar Specifies that XML documents are encoded in the character code page.
This option is useful for processing XML documents that are encoded in the
specified character code page but do not contain an encoding declaration.
For each document, if a declaration tag exists and contains an encoding attribute,
the encoding must match the character code page, otherwise the row containing
the document will be rejected. Note that the character codepage is the value
specified by the codepage file type modifier, or the application codepage if it is
not specified. By default, either the documents are encoded in Unicode, or they
contain a declaration tag with an encoding attribute.
This option is useful for processing XML documents that are encoded in a specific
graphic code page but do not contain an encoding declaration.
For each document, if a declaration tag exists and contains an encoding attribute,
the encoding must match the graphic code page, otherwise the row containing
the document will be rejected. Note that the graphic code page is the graphic
component of the value specified by the codepage file type modifier, or the
graphic component of the application code page if it is not specified. By default,
documents are either encoded in Unicode, or they contain a declaration tag with
an encoding attribute.
Table 54. Valid file type modifiers for the load utility: ASC file formats (Non-delimited ASCII)
Modifier Description
binarynumerics Numeric (but not DECIMAL) data must be in binary form, not the character
representation. This avoids costly conversions.
This option is supported only with positional ASC, using fixed length records
specified by the reclen option.
NULLs cannot be present in the data for columns affected by this modifier.
Blanks (normally interpreted as NULL) are interpreted as a binary value when
this modifier is used.
nochecklengths If nochecklengths is specified, an attempt is made to load each row, even if the
source data has a column definition that exceeds the size of the target table
column. Such rows can be successfully loaded if code page conversion causes the
source data to shrink; for example, 4-byte EUC data in the source could shrink to
2-byte DBCS data in the target, and require half the space. This option is
particularly useful if it is known that the source data will fit in all cases despite
mismatched column definitions.
nullindchar=x x is a single character. Changes the character denoting a NULL value to x. The
default value of x is Y.2
This modifier is case sensitive for EBCDIC data files, except when the character is
an English letter. For example, if the NULL indicator character is specified to be
the letter N, then n is also recognized as a NULL indicator.
This option is supported only with positional ASC, using fixed length records
specified by the reclen option.
NULLs cannot be present in the data for columns affected by this modifier.
Blanks (normally interpreted as NULL) are interpreted as a binary value when
this modifier is used.
Regardless of the server platform, the byte order of binary data in the load source
file is assumed to be big-endian; that is, when using this modifier on Windows
operating systems, the byte order must not be reversed.
This option cannot be specified together with striptnulls. These are mutually
exclusive options. This option replaces the obsolete t option, which is supported
for earlier compatibility only.
striptnulls Truncates any trailing NULLs (0x00 characters) when loading data into a
variable-length field. If this option is not specified, NULLs are kept.
This option cannot be specified together with striptblanks. These are mutually
exclusive options. This option replaces the obsolete padwithzero option, which is
supported for earlier compatibility only.
zoneddecimal Loads zoned decimal data, since the BINARYNUMERICS modifier does not
include the DECIMAL field type. This option is supported only with positional
ASC, using fixed length records specified by the RECLEN option.
The single quotation mark (’) can also be specified as a character string delimiter
as follows:
modified by chardel’’
coldelx x is a single character column delimiter. The default value is a comma (,). The
specified character is used in place of a comma to signal the end of a column.23
decplusblank Plus sign character. Causes positive decimal values to be prefixed with a blank
space instead of a plus sign (+). The default action is to prefix positive decimal
values with a plus sign.
decptx x is a single character substitute for the period as a decimal point character. The
default value is a period (.). The specified character is used in place of a period as
a decimal point character.23
delprioritychar The current default priority for delimiters is: record delimiter, character delimiter,
column delimiter. This modifier protects existing applications that depend on the
older priority by reverting the delimiter priorities to: character delimiter, record
delimiter, column delimiter. Syntax:
db2 load ... modified by delprioritychar ...
With the delprioritychar modifier specified, there will be only two rows in this
data file. The second <row delimiter> will be interpreted as part of the first data
column of the second row, while the first and the third <row delimiter> are
interpreted as actual record delimiters. If this modifier is not specified, there will
be three rows in this data file, each delimited by a <row delimiter>.
keepblanks Preserves the leading and trailing blanks in each field of type CHAR, VARCHAR,
LONG VARCHAR, or CLOB. Without this option, all leading and trailing blanks
that are not inside character delimiters are removed, and a NULL is inserted into
the table for all blank fields.
The following example illustrates how to load data into a table called TABLE1,
while preserving all leading and trailing spaces in the data file:
db2 load from delfile3 of del
modified by keepblanks
insert into table1
nochardel The load utility will assume all bytes found between the column delimiters to be
part of the column’s data. Character delimiters will be parsed as part of column
data. This option should not be specified if the data was exported using DB2
(unless nochardel was specified at export time). It is provided to support vendor
data files that do not have character delimiters. Improper usage might result in
data loss or corruption.
Fixed length target fields are checked to verify that they are large enough for the
data. If nochecklengths is specified, no checking is done, and an attempt is made
to load each row.
nochecklengths If nochecklengths is specified, an attempt is made to load each row, even if the
source data has a column definition that exceeds the size of the target table
column. Such rows can be successfully loaded if code page conversion causes the
source data to shrink; for example, 4-byte EUC data in the source could shrink to
2-byte DBCS data in the target, and require half the space. This option is
particularly useful if it is known that the source data will fit in all cases despite
mismatched column definitions.
Note:
1. Double quotation marks around the date format string are mandatory. Field
separators cannot contain any of the following: a-z, A-Z, and 0-9. The field
separator should not be the same as the character delimiter or field delimiter in
the DEL file format. A field separator is optional if the start and end positions
of an element are unambiguous. Ambiguity can exist if (depending on the
modifier) elements such as D, H, M, or S are used, because of the variable
length of the entries.
For time stamp formats, care must be taken to avoid ambiguity between the
month and the minute descriptors, since they both use the letter M. A month
field must be adjacent to other date fields. A minute field must be adjacent to
other time fields. Following are some ambiguous time stamp formats:
"M" (could be a month, or a minute)
"M:M" (Which is which?)
"M:YYYY:M" (Both are interpreted as month.)
"S:M:YYYY" (adjacent to both a time value and a date value)
In ambiguous cases, the utility will report an error message, and the operation
will fail.
Following are some unambiguous time stamp formats:
"M:YYYY" (Month)
"S:M" (Minute)
"M:YYYY:S:M" (Month....Minute)
"M:H:YYYY:M:D" (Minute....Month)
Some characters, such as double quotation marks and back slashes, must be
preceded by an escape character (for example, \).
2. Character values provided for the chardel, coldel, or decpt file type modifiers
must be specified in the code page of the source data.
The character code point (instead of the character symbol), can be specified
using the syntax xJJ or 0xJJ, where JJ is the hexadecimal representation of the
code point. For example, to specify the # character as a column delimiter, use
one of the following:
... modified by coldel# ...
... modified by coldel0x23 ...
... modified by coldelX23 ...
3. Delimiter considerations for moving data lists restrictions that apply to the
characters that can be used as delimiter overrides.
Authorization
Database
Command syntax
Command parameters
HISTORY timestamp
Identifies a range of entries in the recovery history file that will be deleted.
A complete time stamp (in the form yyyymmddhhmmss), or an initial prefix
(minimum yyyy) can be specified. All entries with time stamps equal to or
less than the time stamp provided are deleted from the recovery history
file.
WITH FORCE OPTION
Specifies that the entries will be pruned according to the time stamp
specified, even if some entries from the most recent restore set are deleted
from the file. A restore set is the most recent full database backup
including any restores of that backup image. If this parameter is not
specified, all entries from the backup image forward will be maintained in
the history.
AND DELETE
Specifies that the associated log archives will be physically deleted (based
on the location information) when the history file entry is removed. This
option is especially useful for ensuring that archive storage space is
recovered when log archives are no longer needed. If you are archiving
logs via a user exit program, the logs cannot be deleted using this option.
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.
LOGFILE PRIOR TO log-file-name
Specifies a string for a log file name, for example S0000100.LOG. All log
files prior to (but not including) the specified log file will be deleted. The
logretain database configuration parameter must be set to RECOVERY or
CAPTURE.
Example
Example 1: Remove all entries from the recovery history file that were written on or
before December 31, 2003:
CALL SYSPROC.ADMIN_CMD (’prune history 20031231’)
Example 2: Delete all log files from the active log file path prior to (but not
including) S0000100.LOG:
CALL SYSPROC.ADMIN_CMD(’prune logfile prior to S0000100.LOG’)
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.
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.
The command affects only the database partition to which the application is
currently connected.
In this mode, only users with authority in this restricted mode are allowed to
connect to the database. Users with sysadm and dbadm authority always have access
to a database while it is quiesced.
Scope
QUIESCE DATABASE results in all objects in the database being in the quiesced
mode. Only the allowed user/group and sysadm, sysmaint, dbadm, or sysctrl will be
able to access the database or its objects.
Authorization
Database
Command syntax
FORCE CONNECTIONS
Command parameters
DEFER
Wait for applications until they commit the current unit of work.
WITH TIMEOUT minutes
Specifies a time, in minutes, to wait for applications to commit the
current unit of work. If no value is specified, in a single-partition
database environment, the default value is 10 minutes. In a
partitioned database environment the value specified by the
start_stop_time database manager configuration parameter will be
used.
IMMEDIATE
Do not wait for the transactions to be committed, immediately rollback the
transactions.
FORCE CONNECTIONS
Force the connections off.
DATABASE
Quiesce the database. All objects in the database will be placed in quiesced
mode. Only specified users in specified groups and users with sysadm,
sysmaint, and sysctrl authority will be able to access to the database or its
objects.
Example
Usage notes
v After QUIESCE DATABASE, users with sysadm, sysmaint, sysctrl, or dbadm
authority, and GRANT/REVOKE privileges can designate who will be able to
connect. This information will be stored permanently in the database catalog
tables.
For example,
Scope
Authorization
Required connection
Database
Command syntax
Command parameters
TABLE
tablename
Specifies the unqualified table name. The table cannot be a system
catalog table.
Example
Usage notes
Once completed, the new connection owns the quiesce, and the load operation can
be restarted.
A quiescer can upgrade the state of a table space from a less restrictive state to a
more restrictive one (for example, S to U, or U to X). If a user requests a state
lower than one that is already held, the original state is returned. States are not
downgraded.
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Note: This topic contains references to some keyword updates that are only valid
when DB2 9.5 Fix Pack 1 is installed. If DB2 9.5 Fix Pack 1 is not yet available or
installed, refer to the DB2 9 version of this topic available in the DB2 9 Information
Center at:http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp
Scope
This command affects all database partitions in the database partition group.
Authorization
Required connection
Redistribute options
,
ONLY
TABLE ( table-name )
FIRST
Add/Drop DB partition:
,
ADD DBPARTITIONNUM ( n )
DBPARTITIONNUMS TO m
,
DROP DBPARTITIONNUM ( n )
DBPARTITIONNUMS TO m
Redistribute options:
STATISTICS NONE
STOP AT local-isotime
Command parameters
DATABASE PARTITION GROUP db-partition-group
The name of the database partition group. This one-part name identifies a
database partition group described in the SYSCAT.DBPARTITIONGROUPS
catalog table. The database partition group cannot currently be undergoing
redistribution.
Usage notes
v When the NOT ROLLFORWARD RECOVERABLE option is specified and the
database is a recoverable database, the first time the utility accesses a table
space, it is put into the BACKUP PENDING state. All the tables in that table
space will become read-only until the table space is backed-up, which can only
be done when all tables in the table space have finished being redistributed.
v When a redistribution operation is running, it produces an event log file
containing general information about the redistribution operation and
information such as the starting and ending time of each table processed. This
event log file is written to the server:
– The homeinst/sqllib/redist directory on Linux and UNIX based systems,
using the following format for subdirectories and file name:
database-name.database-partition-group-name.timestamp.log.
– The DB2INSTPROF\instance\redist directory on Windows operating systems
(where DB2INSTPROF is the value of the DB2INSTPROF registry variable),
using the following format for subdirectories and file name:
database-name.database-partition-group-name.timestamp.log.
– The time stamp value is the time when the command was issued.
For more information about the redistribute event log, refer to the
“Redistribution Error Recovery” topic.
v This utility performs intermittent COMMITs during processing. This can cause
type 2 connections to receive an SQL30090N error.
v All packages having a dependency on a table that has undergone redistribution
are invalidated. It is recommended to explicitly rebind such packages after the
redistribute database partition group operation has completed. Explicit rebinding
eliminates the initial delay in the execution of the first SQL request for the
invalid package. The redistribute message file contains a list of all the tables that
have undergone redistribution.
v By default, the redistribute utility will update the statistics for those tables that
have a statistics profile. For the tables without a statistics profile, it is
recommended that you separately update the table and index statistics for these
tables by calling the db2Runstats API or by issuing the RUNSTATS command
after the redistribute operation has completed.
v Database partition groups containing replicated materialized query tables or
tables defined with DATA CAPTURE CHANGES cannot be redistributed.
v Redistribution is not allowed if there are user temporary table spaces with
existing declared temporary tables in the database partition group.
v Options such as INDEXING MODE are ignored on tables, on which they do not
apply, without warning. For example, INDEXING MODE will be ignored on
tables without indexes.
v Command execution status is returned in the SQLCA resulting from the CALL
statement.
v The file referenced in USING DISTFILE distfilename or USING TARGETMAP
targetmapfilename, must refer to a file on the server.
Compatibilities
You can reorganize all indexes defined on a table by rebuilding the index data into
unfragmented, physically contiguous pages. Alternatively, you have the option of
reorganizing specific indexes on a range partitioned table.
If you specify the CLEANUP ONLY option of the index clause, cleanup is
performed without rebuilding the indexes. This command cannot be used against
indexes on declared temporary tables (SQLSTATE 42995).
Scope
This command affects all database partitions in the database partition group.
Authorization
Required connection
Database
Command syntax
REORG
Table clause:
INDEX index-name
KEEPDICTIONARY
ALLOW NO ACCESS USE tbspace-name INDEXSCAN LONGLOBDATA RESETDICTIONARY
ALLOW READ ACCESS USE longtbspace-name
ALLOW WRITE ACCESS START
INPLACE
ALLOW READ ACCESS NOTRUNCATE TABLE RESUME
STOP
PAUSE
Index clause:
ON DBPARTITIONNUM ( db-partition-number1 )
DBPARTITIONNUMS TO db-partition-number2
ALL DBPARTITIONNUMS
,
Command parameters
INDEXES ALL FOR TABLE table-name
Specifies the table whose indexes are to be reorganized. The table can be in
a local or a remote database.
INDEX index-name
Specifies an individual index to be reorganized on a partitioned table.
Reorganization of individual indexes are only supported for
non-partitioned indexes on a partitioned table. This parameter is not
supported for block indexes.
FOR TABLE table-name
Specifies the table name location of the individual index being reorganized
on a partitioned table. This parameter is optional, given that index names
are unique across the database.
ALLOW NO ACCESS
Specifies that no other users can access the table while the indexes
are being reorganized.
ALLOW READ ACCESS
Specifies that other users can have read-only access to the table
while the indexes are being reorganized. This access level is not
supported for REORG INDEXES of a partitioned table unless the
CLEANUP ONLY option is specified.
CLEANUP ONLY
When CLEANUP ONLY is requested, a cleanup rather than a full
reorganization will be done. The indexes will not be rebuilt and
any pages freed up will be available for reuse by indexes defined
on this table only.
The CLEANUP ONLY PAGES option will search for and free
committed pseudo empty pages. A committed pseudo empty page
is one where all the keys on the page are marked as deleted and
all these deletions are known to be committed. The number of
pseudo empty pages in an indexes can be determined by running
RUNSTATS and looking at the NUM EMPTY LEAFS column in
SYSCAT.INDEXES. The PAGES option will clean the NUM EMPTY
LEAFS if they are determined to be committed.
The CLEANUP ONLY ALL option will free committed pseudo
empty pages, as well as remove committed pseudo deleted keys
from pages that are not pseudo empty. This option will also try to
merge adjacent leaf pages if doing so will result in a merged leaf
page that has at least PCTFREE free space on the merged leaf page,
where PCTFREE is the percent free space defined for the index at
index creation time. The default PCTFREE is ten percent. If two
pages can be merged, one of the pages will be freed. The number
of pseudo deleted keys in an index , excluding those on pseudo
empty pages, can be determined by running RUNSTATS and then
selecting the NUMRIDS DELETED from SYSCAT.INDEXES. The
ALL option will clean the NUMRIDS DELETED and the NUM
EMPTY LEAFS if they are determined to be committed.
ALL Specifies that indexes should be cleaned up by removing
committed pseudo deleted keys and committed pseudo empty
pages.
PAGES
Specifies that committed pseudo empty pages should be removed
from the index tree. This will not clean up pseudo deleted keys on
Usage notes
Restrictions:
v Command execution status is returned in the SQLCA resulting from the CALL
statement.
v The REORG utility issue a COMMIT statement at the beginning of the operation
which, in the case of Type 2 connections, causes the procedure to return
SQL30090N with reason code 2.
v The REORG utility does not support the use of nicknames.
v The REORG TABLE command is not supported for declared temporary tables.
v The REORG TABLE command cannot be used on views.
v Reorganization of a table is not compatible with range-clustered tables, because
the range area of the table always remains clustered.
v REORG TABLE cannot be used on a partitioned table in a DMS table space
while an online backup of ANY table space in which the table resides, including
LOBs and indexes, is being performed.
v REORG TABLE cannot use an index that is based on an index extension.
v If a table is in reorg pending state, an inplace reorg is not allowed on the table.
v For partitioned tables:
– REORG is supported at the table level. Reorganization of an individual data
partition can be achieved by detaching the data partition, reorganizing the
resulting non-partitioned table and then re-attaching the data partition.
– The table must have an ACCESS_MODE in SYSCAT.TABLES of Full Access.
– Reorganization skips data partitions that are in a restricted state due to an
attach or detach operation
– If an error occurs during table reorganization, the non-partitioned indexes of
the table will be marked invalid if the reorganization has reached or passed
the replace phase for the first data partition. Indexes will be rebuilt on the
next access to the table.
– If an error occurs during index reorganization when the ALLOW NONE
access mode is used, some non-partitioned indexes of the table may be left
invalid. For RID indexes on the table, only the index currently being
reorganized at the time of the error will be left invalid. For MDC tables, one
or more of the block indexes could be left invalid if an error occurs. Any
indexes marked invalid will be rebuilt on the next access to the table.
– If a table reorganization operation fails, some data partitions may be in a
reorganized state and others may not. When the REORG TABLE command is
reissued, all the data partitions will be reorganized regardless of the data
partition’s reorganization state.
If an error occurs, an SQLCA dump is written to the history file. For an in-place
table reorganization, the status is recorded as PAUSED.
When an indexed table has been modified many times, the data in the indexes
might become fragmented. If the table is clustered with respect to an index, the
table and index can get out of cluster order. Both of these factors can adversely
affect the performance of scans using the index, and can impact the effectiveness of
index page prefetching. REORG INDEX or REORG INDEXES can be used to
reorganize one or all of the indexes on a table. Index reorganization will remove
any fragmentation and restore physical clustering to the leaf pages. Use the
REORGCHK command to help determine if an index needs reorganizing. Be sure
to complete all database operations and release all locks before invoking index
reorganization. This can be done by issuing a COMMIT after closing all cursors
opened WITH HOLD, or by issuing a ROLLBACK.
Tables that have been modified so many times that data is fragmented and access
performance is noticeably slow are candidates for the REORG TABLE command.
You should also invoke this utility after altering the inline length of a structured
type column in order to benefit from the altered inline length. Use the
REORGCHK command to determine whether a table needs reorganizing. Be sure
to complete all database operations and release all locks before invoking REORG
TABLE. This can be done by issuing a COMMIT after closing all cursors opened
WITH HOLD, or by issuing a ROLLBACK. After reorganizing a table, use
RUNSTATS to update the table statistics, and REBIND to rebind the packages that
use this table. The reorganize utility will implicitly close all the cursors.
If the table contains mixed row format because the table value compression has
been activated or deactivated, an offline table reorganization can convert all the
existing rows into the target row format.
If the table is distributed across several database partitions, and the table or index
reorganization fails on any of the affected database partitions, only the failing
database partitions will have the table or index reorganization rolled back.
If the reorganization is not successful, temporary files should not be deleted. The
database manager uses these files to recover the database.
If the name of an index is specified, the database manager reorganizes the data
according to the order in the index. To maximize performance, specify an index
that is often used in SQL queries. If the name of an index is not specified, and if a
clustering index exists, the data will be ordered according to the clustering index.
If the table contains LOB columns that do not use the COMPACT option, the LOB
DATA storage object can be significantly larger following table reorganization. This
can be a result of the order in which the rows were reorganized, and the types of
table spaces used (SMS or DMS).
Authorization
Required connection
Database
Command syntax
DATABASE MANAGER
DB MANAGER
DBM
CONTAINERS
DATABASES
TABLESPACES
CONTAINER container-name FOR tblspace-name ON database-alias
DATABASE USING health-indicator-name
TABLESPACE tblspace-name
Command parameters
DATABASE MANAGER | DB MANAGER | DBM
Resets alert settings for the database manager.
CONTAINERS
Resets default alert settings for all table space containers managed by the
database manager to the install default. These are the settings that apply to
all table space containers that do not have custom settings. Custom settings
are defined using the CONTAINER container-name FOR tblspace-name ON
database-alias clause.
If you do not specify this option, all health indicators for the specified
object or object type will be reset.
Example
Reset alert settings for the database manager that owns the database which
contains the ADMIN_CMD procedure.
CALL SYSPROC.ADMIN_CMD( ’reset alert cfg for dbm’ )
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
The database-alias must be a local database defined in the catalog on the server
because the ADMIN_CMD procedure runs on the server only.
This command only affects the database partition that the application is connected
to.
Authorization
Required connection
Database
Command syntax
DBPARTITIONNUM db-partition-num
Command parameters
FOR database-alias
Specifies the alias of the database whose configuration is to be reset to the
system defaults. The database alias must be one that is defined in the
catalog on the server, and must refer to a local database on the server.
DBPARTITIONNUM db-partition-num
If a database configuration reset is to be applied to a specific database
partition, this parameter may be used. If this parameter is not provided,
the reset will take effect on all database partitions.
Example
Reset the configuration of a database cataloged with alias SAMPLE on the server
CALL SYSPROC.ADMIN_CMD( ’reset db cfg for SAMPLE’ )
Usage notes
Changes to the database configuration file become effective only after they are
loaded into memory. All applications must disconnect from the database before
this can occur.
Command execution status is returned in the SQLCA resulting from the CALL
statement.
The database alias must be a local database defined in the catalog on the server
because the ADMIN_CMD procedure runs on the server only.
Scope
This command only affects the database partition that the application is connected
to.
Authorization
Required connection
Database
Command syntax
DBPARTITIONNUM db-partition-num
Command parameters
FOR database-alias
Specifies the alias of the database whose configuration is to be reset to the
system defaults. The database alias must be one that is defined in the
catalog on the server, and must refer to a local database on the server.
DBPARTITIONNUM db-partition-num
If a database configuration reset is to be applied to a specific database
Example
Reset the configuration of a database cataloged with alias SAMPLE on the server
CALL SYSPROC.ADMIN_CMD( ’reset db cfg for SAMPLE’ )
Usage notes
Changes to the database configuration file become effective only after they are
loaded into memory. All applications must disconnect from the database before
this can occur.
The database configuration file cannot be reset if the checksum is invalid. This
might occur if the database configuration file is changed without using the
appropriate command. If this happens, the database must be restored to reset the
database configuration file.
Command execution status is returned in the SQLCA resulting from the CALL
statement.
The database alias must be a local database defined in the catalog on the server
because the ADMIN_CMD procedure runs on the server only.
Authorization
Required connection
Database
REWIND TAPE
ON device
Command parameters
ON device
Specifies a valid tape device name. The default value is \\.\TAPE0.The
device specified must be relative to the server.
Example
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
For a table, this utility should be called when the table has had many updates, or
after reorganizing the table. For a statistical view, this utility should be called when
changes to underlying tables have substantially affected the rows returned by the
view. The view must have been previously enabled for use in query optimization
using the ALTER VIEW command.
Scope
This command can be issued from any database partition in the db2nodes.cfg file.
It can be used to update the catalogs on the catalog database partition.
For tables, this command collects statistics for a table on the database partition
from which it is invoked. If the table does not exist on that database partition, the
first database partition in the database partition group is selected.
For views, this command collects statistics using data from tables on all
participating database partitions.
Authorization
You do not need any explicit privilege to use this command on any declared global
temporary table that exists within its connection.
In addition, you need to have appropriate privileges to access rows from the
statistical view. Specifically, for each table, statistical view or nickname referenced
in the statistical view definition, the user must have one of the following
privileges:
v sysadm or dbadm
v CONTROL
v SELECT
Required connection
Database
Command syntax
UTIL_IMPACT_PRIORITY
priority
Statistics Options:
Table Sampling Options Profile Options
REPEATABLE ( integer-literal )
Profile Options:
SET PROFILE
UPDATE ONLY
Index Clause:
INDEXES index-name
DETAILED INDEX ALL
SAMPLED
ON Cols Clause
Distribution Clause
ON Cols Clause
Distribution Clause:
WITH DISTRIBUTION
On Dist Cols Clause
Default Dist Options
On Cols Clause:
ON ALL COLUMNS
,
Frequency Option:
NUM_FREQVALUES integer
Quantile Option:
NUM_QUANTILES integer
Column Option:
column-name
LIKE STATISTICS
,
( column-name )
Command parameters
object-name
Identifies the table or statistical view on which statistics are to be collected.
It must not be a hierarchy table. For typed tables, object-name must be the
name of the root table of the table hierarchy. The fully qualified name or
alias in the form: schema.object-name must be used. The schema is the user
name under which the table was created.
index-name
Identifies an existing index defined on the table. The fully qualified name
in the form schema.index-name must be used. This option cannot be used for
views.
USE PROFILE
This option allows RUNSTATS to employ a previously stored statistics
profile to gather statistics for a table or statistical view. The statistics profile
is created using the SET PROFILE options and is updated using the
UPDATE PROFILE options.
UNSET PROFILE
Specify this option to remove an existing statistics profile. For example,
runstats on tablemyschema.mytable unset profile
FOR INDEXES
Collects and updates statistics for the indexes only. If no table statistics had
Example
Usage notes
1. When there are detached partitions on a partitioned table, index keys that still
belong to detached data partitions which require cleanup will not be counted
as part of the keys in the statistics. These keys are not counted because they
are invisible and no longer part of the table. They will eventually get removed
from the index by asynchronous index cleanup. As a result, statistics collected
before asynchronous index cleanup is run will be misleading. If the
RUNSTATS command is issued before asynchronous index cleanup completes,
it will likely generate a false alarm for index reorganization or index cleanup
based on the inaccurate statistics. Once asynchronous index cleanup is run, all
the index keys that still belong to detached data partitions which require
cleanup will be removed and this may eliminate the need for index
reorganization.
For partitioned tables, you are encouraged to issue the RUNSTATS command
after an asynchronous index cleanup has completed in order to generate
accurate index statistics in the presence of detached data partitions. To
determine whether or not there are detached data partitions in the table, you
can check the status field in the SYSDATAPARTITIONS table and look for the
value I (index cleanup) or D (detached with dependant MQT).
2. Command execution status is returned in the SQLCA resulting from the CALL
statement.
3. It is recommended to run the RUNSTATS command:
Authorization
Required connection
Database
Command syntax
Example
Because DB2 writes a tape mark after every backup image, specifying a position of
1 will move the tape to the start of the second archive on the tape.
CALL SYSPROC.ADMIN_CMD( ’set tape position to 1’ )
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Unless specifically designated, no user except those with sysadm, sysmaint, or sysctrl
has access to a database while it is quiesced. Therefore an UNQUIESCE is required
to restore general access to a quiesced database.
Scope
To stop the instance and unquiesce it and all its databases, issue the db2stop
command. Stopping and restarting DB2 will unquiesce all instances and databases.
Authorization
Command syntax
UNQUIESCE DB
Database
Command parameters
DB Unquiesce the database. User access will be restored to all objects in the
database.
Examples
Unquiescing a Database
CALL SYSPROC.ADMIN_CMD( ’unquiesce db’ )
This command will unquiesce the database that had previously been quiesced.
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Authorization
Required Connection
Database
Command Syntax
ADD ACTION SCRIPT pathname Add Script Details ON State and User Details
TASK task-name
TYPE DB2
STATEMENT TERMINATION CHARACTER character
STMT TERM CHAR
TERM CHAR
OPERATING SYSTEM
OS COMMAND LINE PARAMETERS parms
PARMS
Command Parameters
DATABASE MANAGER
Updates alert settings for the database manager.
DATABASES
Updates alert settings for all databases managed by the database manager.
These are the settings that apply to all databases that do not have custom
settings. Custom settings are defined using the DATABASE ON
database-alias clause.
CONTAINERS
Updates alert settings for all table space containers managed by the
database manager. These are the settings that apply to all table space
containers that do not have custom settings. Custom settings are defined
using the CONTAINER container-name ON database-alias clause.
TABLESPACES
Updates alert settings for all table spaces managed by the database
manager. These are the settings that apply to all table spaces that do not
have custom settings. Custom settings are defined using the TABLESPACE
tblspace-name ON database-alias clause.
DATABASE ON database-alias
Updates the alert settings for the database specified using the ON
is equivalent to
ADD ACTION SCRIPT ... ON ATTENTION QUIESCED_UPDATE
Add an action for the db.log_fs_util indicator that will execute the script
/home/test/scripts/logfsutilact when there is an alarm on the system with
hostname ’plato’.
CALL SYSPROC.ADMIN_CMD( ’update alert cfg for databases using
db.log_fs_util add action script /home/test/scripts/logfsutilact
type os command line parameters "param1 param2" working
directory /tmp on alarm on plato user dricard using mypasswdv’ )
To check the alert configuration after it has been set, you can use the
HEALTH_GET_IND_DEFINITION and HEALTH_GET_ALERT_ACTION_CFG
table functions as follows:
SELECT OBJECTTYPE, ID, CONDITION, ACTIONTYPE,
SUBSTR(ACTIONNAME,1,50) AS ACTION_NAME
FROM TABLE(SYSPROC.HEALTH_GET_ALERT_ACTION_CFG(’DB’,’G’,’’,’’))
AS ALERT_ACTION_CFG
Usage notes
For the ADD ACTION option, the supplied username and password may be exposed
in various places where SQL statement text is captured:
v the network (username/password are passed over the wire unencrypted)
v db2diag.log
v trace files
v dump file
v snapshot monitor (dynamic SQL snapshot)
v system monitor snapshots
v a number of event monitors (statement, deadlock)
v query patroller
v explain tables
v db2pd output (package cache and lock timeout mechanisms, among others)
v DB2 audit records
Command execution status is returned in the SQLCA resulting from the CALL
statement.
The database-alias must be defined in the catalog on the server and be local to the
server.
Authorization
None
Required connection
Command syntax
Command parameters
UPDATE CONTACT name
The name of the contact that will be updated.
USING keyword value
Specifies the contact parameter to be updated (keyword) and the value to
which it will be set (value). The valid set of keywords is:
ADDRESS
The email address that is used by the SMTP server to send the
notification.
TYPE Whether the address is for an email address or a pager.
MAXPAGELEN
The maximum number of characters that the pager can accept.
DESCRIPTION
A textual description of the contact. This has a maximum length of
128 characters.
Example
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Authorization
None
Required Connection
Command Syntax
DESCRIPTION new description
Command Parameters
CONTACTGROUP name
Name of the contact group which will be updated.
ADD CONTACT name
Specifies the name of the new contact to be added to the group. A contact
can be defined with the ADD CONTACT command after it has been added
to a group.
DROP CONTACT name
Specifies the name of a contact in the group that will be dropped from the
group.
ADD GROUP name
Specifies the name of the new contact group to be added to the group.
DROP GROUP name
Specifies the name of a contact group that will be dropped from the group.
DESCRIPTION new description
Optional. A new textual description for the contact group.
Example
Add the contact named ’cname2’ to the contact group named ’gname1’:
CALL SYSPROC.ADMIN_CMD( ’update contactgroup gname1 add contact cname2’ )
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Scope
Authorization
Required connection
Database. The database connection must be local to the instance containing the
connected database.
Command syntax
DBPARTITIONNUM db-partition-num
IMMEDIATE
USING config-keyword value
value AUTOMATIC DEFERRED
AUTOMATIC
MANUAL
Command parameters
AUTOMATIC
Some configuration parameters can be set to AUTOMATIC, allowing DB2
to automatically adjust these parameters to reflect the current resource
requirements. For a list of configuration parameters that support the
AUTOMATIC keyword, refer to the configuration parameters summary. If
a value is specified along with the AUTOMATIC keyword, it might
influence the automatic calculations. For specific details about this
behavior, refer to the documentation for the configuration parameter.
Example
Usage notes
Command execution status is returned in the SQLCA resulting from the CALL
statement.
For more information about DB2 configuration parameters and the values available
for each type of database node, see the individual configuration parameter
descriptions. The values of these parameters differ for each type of database node
configured (server, client, or server with remote clients).
Some changes to the database configuration file become effective only after they
are loaded into memory. All applications must disconnect from the database before
this can occur. For more information on which parameters are configurable on-line
and which ones are not, see summary list of configuration parameters.
If an error occurs, the database configuration file does not change. The database
configuration file cannot be updated if the checksum is invalid. This might occur if
the database configuration file is changed without using the appropriate command.
If this happens, the database must be restored to reset the database configuration
file.
sysadm
Required connection
Database
Command syntax
DEFERRED
USING config-keyword value
value AUTOMATIC
AUTOMATIC
MANUAL
Command parameters
AUTOMATIC
Some configuration parameters can be set to AUTOMATIC, allowing DB2
to automatically adjust these parameters to reflect the current resource
requirements. For a list of configuration parameters that support the
AUTOMATIC keyword, refer to the configuration parameters summary. If
a value is specified along with the AUTOMATIC keyword, it might
influence the automatic calculations. For specific details about this
behavior, refer to the documentation for the configuration parameter.
Example
To view or print a list of the database manager configuration parameters, use the
SYSIBMADM.DBMCFG administrative view. To reset the database manager
configuration parameters to the recommended database manager defaults, use the
RESET DATABASE MANAGER CONFIGURATION command through the
ADMIN_CMD procedure. For more information about database manager
configuration parameters and the values of these parameters appropriate for each
type of database node configured (server, client, or server with remote clients), see
individual configuration parameter descriptions.
Some changes to the database manager configuration file become effective only
after they are loaded into memory. For more information on which parameters are
configurable online and which ones are not, see the configuration parameter
summary. Server configuration parameters that are not reset immediately are reset
during execution of db2start. For a client configuration parameter, parameters are
reset the next time you restart the application. If the client is the command line
processor, it is necessary to invoke TERMINATE.
If an error occurs, the database manager configuration file does not change.
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Updates can only be made to the database instance that contains the connected
database.
Authorization
Database
Command Syntax
Command Parameters
ADD GROUP name
Add a new contact group that will notified of the health of the instance.
ADD CONTACT name
Add a new contact that will notified of the health of the instance.
DROP GROUP name
Removes the contact group from the list of contacts that will notified of the
health of the instance.
DROP CONTACT name
Removes the contact from the list of contacts that will notified of the health
of the instance.
Example
Add the contact group ’gname1’ to the health notification contact list:
CALL SYSPROC.ADMIN_CMD( ’update notification list add group gname1’ )
Usage note
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Authorization
Database
Command syntax
Command parameters
FOR object-part
Specifies the identifier for the history entry to be updated. It is a time
stamp with an optional sequence number from 001 to 999. This parameter
cannot be used to update the entry status. To update the entry status,
specify an EID instead.
EID eid
Specifies the history entry ID.
LOCATION new-location
Specifies the new physical location of a backup image. The interpretation
of this parameter depends on the device type.
DEVICE TYPE new-device-type
Specifies a new device type for storing the backup image. Valid device
types are:
D Disk
K Diskette
T Tape
A Tivoli Storage Manager
F Snapshot backup
U User exit
P Pipe
N Null device
X XBSA
Q SQL statement
O Other
COMMENT new-comment
Specifies a new comment to describe the entry.
STATUS new-status
Specifies a new status for an entry. Only backup entries can have their
status updated. Valid values are:
A Active. The backup image is on the active log chain. Most entries
are active.
Example
To update the history file entry for a full database backup taken on April 13, 1997
at 10:00 a.m., enter:
CALL SYSPROC.ADMIN_CMD(’update history
for 19970413100000001 with location
/backup/dbbackup.1 device type d’)
Usage notes
The primary purpose of the database history file is to record information, but the
data contained in the history is used directly by automatic restore operations.
During any restore where the AUTOMATIC option is specified, the history of
backup images and their locations will be referenced and used by the restore
utility to fulfill the automatic restore request. If the automatic restore function is to
be used and backup images have been relocated since they were created, it is
recommended that the database history record for those images be updated to
reflect the current location. If the backup image location in the database history is
not updated, automatic restore will not be able to locate the backup images, but
manual restore commands can still be used successfully.
Command execution status is returned in the SQLCA resulting from the CALL
statement.
The object-part or eid must refer to the log history entries on the connected database
partition.
Authorization
Database
Command syntax
Command parameter
partitionnum
partitionnum is an integer. If -1 or a non-existing database partition
number is used, the STMM tuning database partition will use the default
database partition as defined for the STMM feature. If -1 or a non-existing
database partition number is used, DB2 will automatically select an
appropriate database partition on which to run the STMM memory tuner.
Example
Update the user preferred self tuning memory manager (STMM) tuning database
partition to database partition 3.
CALL SYSPROC.ADMIN_CMD( ’update stmm tuning dbpartitionnum 3’ )
Usage notes
The STMM tuning process periodically checks for a change in the user preferred
STMM tuning database partition number value. The STMM tuning process will
move to the user preferred STMM tuning database partition if partitionnum exists
and is an active database partition. Once this command changes the STMM tuning
database partition number an immediate change is made to the current STMM
tuning database partition number.
Command execution status is returned in the SQLCA resulting from the CALL
statement.
Syntax
ADMIN_GET_DBP_MEM_USAGE ( )
dbpartitionnum
Authorization
Information returned
Table 61. The result set for ADMIN_GET_DBP_MEM_USAGE
Column Name Data Type Description
DBPARTITIONNUM SMALLINT The database partition number from which memory usage
statistics is retrieved.
MAX_PARTITION_MEM BIGINT The maximum amount of instance memory (in bytes) allowed
to be consumed in the database partition.
CURRENT_PARTITION_MEM BIGINT The amount of instance memory (in bytes) currently consumed
in the database partition.
PEAK_PARTITION_MEM BIGINT The peak or high watermark consumption of instance memory
(in bytes) in the database partition.
Examples
1 record(s) selected.
Example 2: Retrieve memory usage statistics from the currently connected partition
(assuming the user is connected to the database at partition 2.)
SELECT * FROM TABLE (SYSPROC.ADMIN_GET_DBP_MEM_USAGE(-1)) AS T
1 record(s) selected.
4 record(s) selected.
Syntax
ADMIN_GET_MSGS ( operation_id )
Authorization
Example
Check all the messages returned by EXPORT utility that was executed through
ADMIN_CMD procedure, with operation ID ’24523_THERESAX’
SELECT * FROM TABLE(SYSPROC.ADMIN_GET_MSGS(’24523_THERESAX’)) AS MSG
2 record(s) selected.
Usage notes
The query statement that invokes this table function with the appropriate
operation_id can be found in the MSG_RETRIEVAL column of the first result set
returned by the ADMIN_CMD procedure.
Authorization
Syntax
ADMIN_GET_TAB_COMPRESS_INFO ( tabschema , tabname , execmode )
Authorization
Examples
1 record(s) selected.
1 record(s) selected.
Example 3: Determine the total dictionary size for all tables in the schema SIMAP2
SELECT TABSCHEMA, TABNAME, DICT_BUILDER,
(COMPRESS_DICT_SIZE+EXPAND_DICT_SIZE) AS TOTAL_DICT_SIZE,
DBPARTITIONNUM, DATA_PARTITION_ID
FROM TABLE (SYSPROC.ADMIN_GET_TAB_COMPRESS_INFO(’SIMAP2’, ’’, ’REPORT’)) AS T
28 record(s) selected.
4 record(s) selected.
Usage Notes
v If both the tabschema and tabname are specified, information is returned for that
specific table only.
v If the tabschema is specified but tabname is empty (″) or NULL, information is
returned for all tables in the given schema.
v If the tabschema is empty (″) or NULL and tabname is specified, an error is
returned. To retrieve information for a specific table, the table must be identified
by both schema and table name.
v If both tabschema and tabname are empty (″) or NULL, information is returned for
all tables.
v If tabschema or tabname do not exist, or tabname does not correspond to a table
name (type T), a materialized query table name (type S) or a hierarchy table
name (type H), an empty result set is returned.
v When the ADMIN_GET_TAB_COMPRESS_INFO table function is retrieving data
for a given table, it will acquire a shared lock on the corresponding row of
SYSTABLES to ensure consistency of the data that is returned (for example, to
ensure that the table is not altered while information is being retrieved for it).
The lock will only be held for as long as it takes to retrieve the compression
information for the table, and not for the duration of the table function call.
Syntax
ADMIN_REMOVE_MSGS ( operation_id )
Procedure parameter
operation_id
An input argument of type VARCHAR(139) that specifies the operation ID of
the message file(s) produced by a data movement utility that was executed
through the ADMIN_CMD procedure. The operation ID is generated by the
ADMIN_CMD procedure.
Authorization
Example
Usage notes
The CALL statement that invokes this procedure with the appropriate operation_id
can be found in the MSG_REMOVAL column of the first result set returned by
ADMIN_CMD procedure.
The ADMINTABINFO administrative view returns size and state information for
tables, materialized query tables (MQT) and hierarchy tables only. These table
types are reported as T for table, S for materialized query tables and H for
Authorization
Examples
Example 3: Identify tables that are eligible to use large RIDs, but are not currently
enabled to use large RIDs.
SELECT TABSCHEMA, TABNAME FROM SYSIBMADM.ADMINTABINFO
WHERE LARGE_RIDS = ’P’
Example 4: Identify which tables are using type-1 indexes and require a
reorganization to convert to type-2 indexes.
SELECT TABSCHEMA, TABNAME FROM SYSIBMADM.ADMINTABINFO
WHERE INDEX_TYPE = 1
Syntax
ADMIN_GET_TAB_INFO_V95 ( tabschema , tabname )
Authorization
Examples
Example 1: Retrieve size and state information for the table DBUSER1.EMPLOYEE.
SELECT * FROM TABLE (SYSPROC.ADMIN_GET_TAB_INFO_V95(’DBUSER1’, ’EMPLOYEE’))
AS T
Calculate how much space would be required if the table were moved to another
table space, where the new table space has the same page size and extent size as
the original table space:
SELECT (data_object_l_size + index_object_l_size + long_object_l_size +
lob_object_l_size + xml_object_l_size) as total_l_size
FROM TABLE( SYSPROC.ADMIN_GET_TAB_INFO_V95( ’DBUSER1’, ’EMPLOYEE’ )) AS T
Example 3: Check the current type of statistics information collected for table T1
db2 => select substr(tabschema, 1, 10) as tbschema, substr(tabname, 1, 10)
as tbname, statstype from SYSIBMADM.ADMINTABINFO where tabname = ’T1’;
1 record(s) selected.
Usage notes
v If both the tabschema and tabname are specified, information is returned for that
specific table only.
v If the tabschema is specified but tabname is empty (″) or NULL, information is
returned for all tables in the given schema.
v If the tabschema is empty (″) or NULL and tabname is specified, an error is
returned. To retrieve information for a specific table, the table must be identified
by both schema and table name.
v If both tabschema and tabname are empty (″) or NULL, information is returned for
all tables.
v If tabschema or tabname do not exist, or tabname does not correspond to a table
name (type T), a materialized query table name (type S) or a hierarchy table
name (type H), an empty result set is returned.
v When the ADMIN_GET_TAB_INFO_V95 table function is retrieving data for a
given table, it will acquire a shared lock on the corresponding row of
SYSTABLES to ensure consistency of the data that is returned (for example, to
ensure that the table is not dropped while information is being retrieved for it).
REDISTRIBUTING_PENDING
1. no redistribute has been run for the given table N
2. redistribute started to run on the database partition group but not on the table
N
3. redistribute failed in the phase before moving data N
4. redistribute failed in the phase of moving data Y
5. redistribute completely successfully and committed for the table. N
Syntax
AUDIT_ARCHIVE ( directory , dbpartitionnum )
The syntax is the same for both the procedure and table function.
Examples
Example 1: Archive the audit log(s) for all database partitions to the default
directory using the procedure.
CALL SYSPROC.AUDIT_ARCHIVE(NULL, NULL)
Example 2: Archive the audit log(s) for all database partitions to the default
directory using the table function.
SELECT * FROM TABLE(SYSPROC.AUDIT_ARCHIVE(’’, -2)) AS T1
Information returned
Table 65. Information returned by the AUDIT_ARCHIVE procedure and table function
Column name Data type Description
DBPARTITIONNUM INTEGER Partition number of archived file.
PATH VARCHAR(1024) Directory location of archived file.
FILE VARCHAR(1024) Name of the archived file.
SQLCODE INTEGER The SQLCODE received while attempting to
archive file.
SQLSTATE VARCHAR(5) The SQLSTATE received while attempting
archive file. If SQLSTATE is NULL, the value
is zero.
SQLERRMC VARCHAR(70) The sqlerrmc received while attempting
FOR BIT DATA archive file. If SQLSTATE is NULL, the value
is zero.
Syntax
file_mask , event_options )
Procedure parameters
delimiter
An optional input argument of type VARCHAR(1) that specifies the character
delimiter to be used in the delimited files. If the argument is null or an empty
string, a double quote will be used as the delimiter.
Authorization
Examples
Note: Audit log files contain a timestamp as part of their naming convention.
Example 1:Performs a delimited extract on all audit log files archived on June 18th,
2007 in the default archive directory. This example is extracting just execute events,
using a double quote (″) character delimiter, and creating or appending the
resulting extract files (<category>.del) in the $HOME/audit_delim_extract
directory.
CALL SYSPROC.AUDIT_DELIM_EXTRACT(NULL, ’$HOME/AUDIT_DELIM_EXTRACT’, NULL,
’%20070618%’, ’CATEGORIES EXECUTE STATUS BOTH’)
Syntax
AUDIT_LIST_LOGS ( directory )
Procedure parameters
directory
An optional input argument of type VARCHAR(1024) that specifies the
directory where the archived audit file(s) will be written. The directory must
exist on the server and the instance owner must be able to create files in that
directory. If the argument is null or an empty string, then the search default
directory is used.
Examples
Example 1: Lists all archived audit logs in the default audit archive directory:
SELECT * FROM TABLE(SYSPROC.AUDIT_LIST_LOGS(’’)) AS T1
Note: This only lists the logs in the directory for database on which the query is
run. Archived files have the format db2audit.db.<dbname>.log.<timestamp>
Information Returned
Table 66. The information returned for AUDIT_LIST_LOGS
Column Name Data Type Description
PATH VARCHAR(1024) Path location of the archived file.
FILE VARCHAR(1024) Filename of the archived file.
SIZE BIGINT File size of the archived file.
Syntax
AUTOMAINT_GET_POLICY ( policy_type , policy )
Procedure parameters
policy_type
An input argument of type VARCHAR(128) that specifies the type of automatic
maintenance policy to retrieve. The value can be one of the following:
AUTO_BACKUP
automatic backup
AUTO_REORG
automatic table and index reorganization
AUTO_RUNSTATS
automatic table runstats operations
MAINTENANCE_WINDOW
maintenance window
Authorization
Example
Syntax
AUTOMAINT_GET_POLICYFILE ( policy_type , policy_file_name )
Procedure parameters
policy_type
An input argument of type VARCHAR(128) that specifies the type of automatic
maintenance policy to retrieve. The value can be one of the following:
AUTO_BACKUP
automatic backup
AUTO_REORG
automatic table and index reorganization
AUTO_RUNSTATS
automatic table runstats operations
MAINTENANCE_WINDOW
maintenance window
Note: The file name may be prefixed with a path relative to tmp. In that case
the directory should exist, should have permission to create/overwrite the file
and the correct path separator for the DB2 Server must be used.
For example:
On UNIX if the instance directory is defined as $HOME/sqllib. For a policy
file named ’policy.xml’, the file name will be ’$HOME/sqllib/tmp/policy.xml’
On Windows, the instance directory name can be determined from the values
of the DB2INSTPROF registry variable and the DB2INSTANCE environment
variable. For a policy file named ’policy.xml’, if db2set gives
DB2INSTPROF=C:\DB2PROF and %DB2INSTANCE%=db2, then the file name
will be C:\DB2PROF\db2\tmp\policy.xml
Authorization
Example
This will create an XML file named AutoBackup.xml in the tmp subdirectory under
the DB2 instance directory.
Syntax
AUTOMAINT_SET_POLICY ( policy_type , policy )
Authorization
Example
This will replace the current automatic statistics collection configuration with the
new configuration contained in the XML document that is passed as the second
parameter to the procedure.″
Syntax
AUTOMAINT_SET_POLICYFILE ( policy_type , policy_file_name )
Note: When the file name is specified with a relative path, the correct path
separator for the DB2 Server must be used and the directory and file should
exist with read permission.
For example:
On UNIX if the instance directory is defined as $HOME/sqllib. For a policy
file named ’automaint/policy.xml’, the file name will be ’$HOME/sqllib/tmp/
automaint/policy.xml’
On Windows, the instance directory name can be determined from the values
of the DB2INSTPROF registry variable and the DB2INSTANCE environment
variable. For a policy file named ’automaint\policy.xml’, if db2set gives
DB2INSTPROF=C:\DB2PROF and %DB2INSTANCE%=db2, then the file name
will be C:\DB2PROF\db2\tmp\automaint\policy.xml
Authorization
Example
This will replace the current automatic backup configuration settings with the new
configuration contained in the AutoBackup.xml file located in the tmp directory
under the DB2 instance directory.
DB_PARTITIONS
The DB_PARTITIONS table function returns the contents of the db2nodes.cfg file in
table form.
Syntax
DB_PARTITIONS ( )
Example
3 record(s) selected.
Information returned
Table 67. Information returned by the DB_PARTITIONS table function
Column name Data type Description
PARTITION_NUMBER SMALLINT A unique number between 0
and 999 that identifies a
database partition server in a
partitioned database
environment.
HOST_NAME VARCHAR(128) The TCP/IP host name of the
database partition server.
PORT_NUMBER SMALLINT The port number for the
database partition server.
SWITCH_NAME VARCHAR(128) The name of a high speed
interconnect, or switch, for
database partition
communications.
Authorization
8 record(s) selected.
Example 2: Retrieve all the database configuration parameters values stored on disk
for all database partitions.
SELECT NAME, DEFERRED_VALUE, DBPARTITIONNUM FROM SYSIBMADM.DBCFG
Information returned
Table 68. Information returned by the DBCFG administrative view
Column name Data type Description
NAME VARCHAR(32) Configuration parameter
name.
VALUE VARCHAR(1024) The current value of the
configuration parameter
stored in memory.
VALUE_FLAGS VARCHAR(10) Provides specific information
for the configuration
parameter current value.
Valid values are:
v NONE - no additional
information
v AUTOMATIC - the
configuration parameter
has been set to automatic
Authorization
Examples
Example 1: Retrieve values for all the database manager configuration parameters
stored on disk:
SELECT NAME, DEFERRED_VALUE FROM SYSIBMADM.DBMCFG
Information returned
Table 69. Information returned by the DBMCFG administrative view
Column name Data type Description
NAME VARCHAR(32) Configuration parameter
name.
VALUE VARCHAR(256) The current value of the
configuration parameter
stored in memory.
VALUE_FLAGS VARCHAR(10) Provides specific information
for the configuration
parameter current value.
Valid values are:
v NONE - no additional
information
v AUTOMATIC - the
configuration parameter
has been set to automatic
DEFERRED_VALUE VARCHAR(256) The value of the
configuration parameter on
disk. For some database
manager configuration
parameters, the database
manager must be stopped
(db2stop) and restarted
(db2start) for this value to
take effect.
DEFERRED_VALUE_FLAGS VARCHAR(10) Provides specific information
for the configuration
parameter deferred value.
Valid values are:
v NONE - no additional
information
v AUTOMATIC - the
configuration parameter
has been set to automatic
DATATYPE VARCHAR(128) Configuration parameter data
type.
Authorization
Example
Request the DB2 registry settings that are currently being used.
SELECT * from SYSIBMADM.REG_VARIABLES
6 record(s) selected.
Information returned
Table 70. Information returned by the REG_VARIABLES administrative view
Column name Data type Description
DBPARTITIONNUM SMALLINT Logical partition number of
each database partition on
which the function operates.
REG_VAR_NAME VARCHAR(256) Name of the DB2 registry
variable.
REG_VAR_VALUE VARCHAR(2048) Current setting of the DB2
registry variable.
IS_AGGREGATE SMALLINT Indicates whether or not the
DB2 registry variable is an
aggregate variable. The
possible return values are 0 if
it is not an aggregate
variable, and 1 if it is an
aggregate variable.
Environment views
Authorization
Example
Information returned
Table 71. Information returned by the ENV_INST_INFO administrative view
Column name Data type Description
INST_NAME VARCHAR(128) Name of the current instance.
IS_INST_PARTITIONABLE SMALLINT Indicates whether or not the
current instance is a
partitionable database server
instance. Possible return
values are 0 if it is not a
partitionable database server
instance, and 1 if it is a
partitionable database server
instance.
NUM_DBPARTITIONS INTEGER Number of database
partitions. If it is not a
partitioned database
environment, returns a value
of 1.
INST_PTR_SIZE INTEGER Bit size of the current
instance (32 or 64).
RELEASE_NUM VARCHAR(128) Internal release number, as
returned by the db2level
command; for example,
03030106.
SERVICE_LEVEL VARCHAR(128) Service level, as returned by
the db2level command; for
example, DB2 v8.1.1.80.
BLD_LEVEL VARCHAR(128) Build level, as returned by
the db2level command; for
example, n041021.
PTF VARCHAR(128) Program temporary fix (PTF)
identifier, as returned by the
db2level command; for
example, U498350.
FIXPACK_NUM INTEGER Fix Pack number, as returned
by the db2level command;
for example, 9.
Example
Authorization
Example
Authorization
Example
1 record(s) selected.
Information returned
Table 74. Information returned by the ENV_SYS_INFO administrative view
Column name Data type Description
OS_NAME VARCHAR(256) Name of the operating
system.
Authorization
Example
SELECT SUBSTR(NAME,1,20) AS NAME, SUBSTR(VALUE,1,10) AS VALUE,
SUBSTR(DATATYPE,1,10) AS DATATYPE, DBPARTITIONNUM
FROM SYSIBMADM.ENV_SYS_RESOURCES
WHERE SUBSTR(NAME,1,8)=’CPU_LOAD’ OR NAME=’CPU_USAGE_TOTAL’
4 record(s) selected.
HEALTH_CONT_HI
The HEALTH_CONT_HI table function returns health indicator information for
table space containers from a health snapshot of table spaces in a database.
Syntax
HEALTH_CONT_HI ( dbname , dbpartitionnum )
Example
SELECT * FROM TABLE(HEALTH_CONT_HI(’’,-1)) AS T
5 record(s) selected.
Information returned
Table 77. Information returned by the HEALTH_CONT_HI table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
CONTAINER_NAME VARCHAR(256) container_name - Container
name
NODE_NUMBER INTEGER node_number - Node number
HI_ID BIGINT A number that uniquely
identifies the health indicator
in the snapshot data stream.
HI_VALUE SMALLINT The value of the health
indicator.
HI_TIMESTAMP TIMESTAMP The date and time that the
alert was generated.
HI_ALERT_STATE BIGINT The severity of the alert.
HEALTH_CONT_HI_HIS
Returns health indicator history information for containers from a health snapshot
of a database.
Syntax
HEALTH_CONT_HI_HIS ( dbname , dbpartitionnum )
Authorization
Example
SELECT * FROM TABLE(HEALTH_CONT_HI_HIS(’’,-1)) AS T
10 record(s) selected.
Information returned
Table 78. Information returned by the HEALTH_CONT_HI_HIS table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
CONTAINER_NAME VARCHAR(256) container_name - Container
name
NODE_NUMBER INTEGER node_number - Node
number
HI_ID BIGINT A number that uniquely
identifies the health indicator
in the snapshot data stream.
HI_TIMESTAMP TIMESTAMP The date and time that the
alert was generated.
HI_VALUE SMALLINT The value of the health
indicator.
HI_ALERT_STATE BIGINT The severity of the alert.
HI_ALERT_STATE_DETAIL VARCHAR(20) The text description of the
HI_ALERT_STATE column.
HEALTH_CONT_INFO
The HEALTH_CONT_INFO table function returns container information from a
health snapshot of a database.
Syntax
HEALTH_CONT_INFO ( dbname , dbpartitionnum )
Authorization
EXECUTE privilege on the HEALTH_CONT_INFO table function.
Example
SELECT * FROM TABLE(HEALTH_CONT_INFO(’’,-1)) AS T
5 record(s) selected.
Information returned
Table 79. Information returned by the HEALTH_CONT_INFO table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
CONTAINER_NAME VARCHAR(256) container_name - Container
name
TABLESPACE_NAME VARCHAR(128) tablespace_name - Table
space name
NODE_NUMBER INTEGER node_number - Node number
ROLLED_UP_ALERT_STATE BIGINT The most severe alert state
captured by this snapshot.
VARCHAR(20) The text description of the
ROLLED_UP_ALERT_ ROLLED_UP_ALERT_STATE
STATE_DETAIL column.
HEALTH_DB_HI
The HEALTH_DB_HI table function returns health indicator information from a
health snapshot of a database.
Syntax
Authorization
Example
SELECT * FROM TABLE(HEALTH_DB_HI(’’,-1)) AS T
11 record(s) selected.
Information returned
Table 80. Information returned by the HEALTH_DB_HI table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
HI_ID BIGINT A number that uniquely
identifies the health indicator
in the snapshot data stream.
DB_NAME VARCHAR(128) db_name - Database name
HI_VALUE SMALLINT The value of the health
indicator.
HI_TIMESTAMP TIMESTAMP The date and time that the
alert was generated.
HI_ALERT_STATE BIGINT The severity of the alert.
HI_ALERT_STATE_DETAIL VARCHAR(20) The text description of the
HI_ALERT_STATE column.
HI_FORMULA VARCHAR(2048) The formula used to calculate
the health indicator.
HI_ADDITIONAL_INFO VARCHAR(4096) Additional information about
the health indicator.
HEALTH_DB_HI_HIS
The HEALTH_DB_HI_HIS table function returns health indicator history
information from a health snapshot of a database.
Authorization
Example
SELECT * FROM TABLE(HEALTH_DB_HI_HIS(’’,-1)) AS T
HEALTH_DB_HIC
The HEALTH_DB_HIC function returns collection health indicator information
from a health snapshot of a database.
Syntax
HEALTH_DB_HIC ( dbname , dbpartitionnum )
Example
SELECT * FROM TABLE(HEALTH_DB_HIC(’’,-1)) AS T
2 record(s) selected.
Information returned
Table 82. Information returned by the HEALTH_DB_HIC table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
HI_ID BIGINT A number that uniquely
identifies the health indicator
in the snapshot data stream.
DB_NAME VARCHAR(128) db_name - Database name
HI_OBJ_NAME VARCHAR(256) A name that uniquely
identifies an object in the
collection.
HI_OBJ_DETAIL VARCHAR(4096) Text that describes why the
object was added to the
collection.
HEALTH_DB_HIC_HIS
Returns collection health indicator history information from a health snapshot of a
database.
Syntax
HEALTH_DB_HIC_HIS ( dbname , dbpartitionnum )
Authorization
Example
SELECT * FROM TABLE(HEALTH_DB_HIC_HIS(’’,-1)) AS T
10 record(s) selected.
HEALTH_DB_INFO
The HEALTH_DB_INFO table function returns information from a health snapshot
of a database.
Syntax
HEALTH_DB_INFO ( dbname , dbpartitionnum )
Authorization
Example
SELECT * FROM TABLE(HEALTH_DB_INFO(’’,-1)) AS T
1 record(s) selected.
Information returned
Table 84. Information returned by the HEALTH_DB_INFO table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
INPUT_DB_ALIAS VARCHAR(128) input_db_alias - Input
database alias
DB_PATH VARCHAR(1024) db_path - Database path
HEALTH_DBM_HI
The HEALTH_DBM_HI table function returns health indicator information from a
health snapshot of the DB2 database manager.
Syntax
HEALTH_DBM_HI ( dbpartitionnum )
Authorization
Example
SELECT * FROM TABLE(HEALTH_DBM_HI(-1)) AS T
2 record(s) selected.
HEALTH_DBM_HI_HIS
The HEALTH_DBM_HI_HIS table function returns health indicator history
information from a health snapshot of the DB2 database manager.
Syntax
HEALTH_DBM_HI_HIS ( dbpartitionnum )
Authorization
18 record(s) selected.
Information returned
Table 86. Information returned by the HEALTH_DBM_HI_HIS table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
HI_ID BIGINT A number that uniquely
identifies the health indicator
in the snapshot data stream.
SERVER_INSTANCE_NAME VARCHAR(128) server_instance_name -
Server instance name
HI_VALUE SMALLINT The value of the health
indicator.
HI_TIMESTAMP TIMESTAMP The date and time that the
alert was generated.
HI_ALERT_STATE BIGINT The severity of the alert.
HI_ALERT_STATE_DETAIL VARCHAR(20) The text description of the
HI_ALERT_STATE column.
HI_FORMULA VARCHAR(2048) The formula used to calculate
the health indicator.
HI_ADDITIONAL_INFO VARCHAR(4096) Additional information about
the health indicator.
HEALTH_DBM_INFO
The HEALTH_DBM_INFO function returns information from a health snapshot of
the DB2 database manager.
Syntax
HEALTH_DBM_INFO ( dbpartitionnum )
Example
SELECT * FROM TABLE(HEALTH_DBM_INFO(-1)) AS T
1 record(s) selected.
Information returned
Table 87. Information returned by the HEALTH_DBM_INFO table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
SERVER_INSTANCE_NAME VARCHAR(128) server_instance_name -
Server instance name
ROLLED_UP_ALERT_STATE BIGINT The most severe alert state
captured by this snapshot.
VARCHAR(20) The text description of the
ROLLED_UP_ALERT_ ROLLED_UP_ALERT_STATE
STATE_DETAIL column.
DB2START_TIME TIMESTAMP db2start_time - Start database
manager timestamp
LAST_RESET TIMESTAMP last_reset - Last reset
timestamp
INTEGER num_nodes_in_db2_instance -
NUM_NODES_IN_DB2_ Number of nodes in database
INSTANCE partition
objectname )
Authorization
Examples
Example 1: Retrieve object level alert action configuration settings for database
SAMPLE for health indicator ID 1004.
SELECT OBJECTTYPE, CFG_LEVEL, SUBSTR(DBNAME,1,8) AS DBNAME,
SUBSTR(OBJECTNAME,1,8) AS OBJECTNAME, ID, IS_DEFAULT,
SUBSTR(CONDITION,1,10) AS CONDITION, ACTIONTYPE,
SUBSTR(ACTIONNAME,1,30) AS ACTIONNAME, SUBSTR(USERID,1,8) AS USERID,
SUBSTR(HOSTNAME,1,10) AS HOSTNAME, SCRIPT_TYPE,
SUBSTR(WORKING_DIR,1,10) AS WORKING_DIR, TERMINATION_CHAR,
SUBSTR(PARAMETERS,1,10) AS PARAMETERS
FROM TABLE(HEALTH_GET_ALERT_ACTION_CFG(’DB’,’O’,’SAMPLE’,’’)) AS ACTION_CFG
WHERE ID = 1004
2 record(s) selected.
Example 2: Retrieve the condition, action type, action name, hostname, and script
type for database SAMPLE for health indicator ID 1004.
SELECT CONDITION, ACTIONTYPE, SUBSTR(ACTIONNAME,1,35) AS ACTIONNAME,
SUBSTR(USERID,1,8) AS USERID, SUBSTR(HOSTNAME,1,10) AS HOSTNAME, SCRIPT_TYPE
FROM TABLE(HEALTH_GET_ALERT_ACTION_CFG(’DB’,’O’,’SAMPLE’,’’)) AS ALERT_ACTION_CFG
WHERE ID=1004
2 record(s) selected.
Usage notes
Information returned
Table 88. Information returned by the HEALTH_GET_ALERT_ACTION_CFG table function
Column name Data type Description
OBJECTTYPE VARCHAR(3) Object type.
CFG_LEVEL CHAR(1) Configuration level.
DBNAME VARCHAR(128) Database name.
OBJECTNAME VARCHAR(512) Object name.
ID BIGINT Health indicator ID.
Syntax
HEALTH_GET_ALERT_CFG ( objecttype , cfg_level , dbname ,
objectname )
Authorization
Examples
Example 1: Retrieve the object level alert configuration settings for database
SAMPLE.
SELECT * FROM TABLE(SYSPROC.HEALTH_GET_ALERT_CFG(’DB’,’O’,’SAMPLE’,’’))
AS ALERT_CFG
Example 2: Retrieve the warning and alarm thresholds for the health indicator ID
’2002’ for table space USERSPACE1 in database SAMPLE.
SELECT WARNING_THRESHOLD, ALARM_THRESHOLD
FROM TABLE(SYSPROC.HEALTH_GET_ALERT_CFG(’TS’,’O’,’SAMPLE’,’USERSPACE1’))
AS T WHERE ID = 2002
Usage notes
Information returned
Table 89. Information returned by the HEALTH_GET_ALERT_CFG table function
Column name Data type Description
OBJECTTYPE VARCHAR(3) Object type.
CFG_LEVEL VARCHAR(1) Configuration level.
DBNAME VARCHAR(128) Database name.
OBJECTNAME VARCHAR(512) Object name.
ID BIGINT Health indicator ID.
IS_DEFAULT SMALLINT Whether the settings is the
default: 1 if it is the default, 0
if it is not the default or Null
if not applicable.
WARNING_THRESHOLD BIGINT Warning threshold. Null if
not applicable.
ALARM_THRESHOLD BIGINT Alarm threshold. Null if not
applicable.
SENSITIVITY BIGINT Health indicator sensitivity.
EVALUATE SMALLINT 1 if this health indicator is
being evaluated or 0 if it is
not being evaluated.
ACTION_ENABLED SMALLINT 1 if an action is enabled to
run upon an alert occurrence
or 0 if no action is enabled to
run upon an alert occurrence.
Authorization
Examples
Example 1: Retrieve the type and short description for health indicator
db.db_op_status in French.
SELECT TYPE, SHORT_DESCRIPTION
FROM TABLE(SYSPROC.HEALTH_GET_IND_DEFINITION(’fr_FR’))
AS IND_DEFINITION WHERE NAME = ’db.db_op_status’
1 record(s) selected.
Example 2: Retrieve the short description for health indicator ID 1001 in English.
SELECT SHORT_DESCRIPTION FROM TABLE(SYSPROC.HEALTH_GET_IND_DEFINITION(’en_US’)
AS IND_DEFINITION WHERE ID = 1001
Information returned
Table 90. Information returned by the HEALTH_GET_IND_DEFINITION table function
Column name Data type Description
ID BIGINT Health indicator ID.
NAME VARCHAR(128) Health indicator name.
SHORT_DESCRIPTION VARCHAR(1024) Health indicator short
description.
LONG_DESCRIPTION VARCHAR(32672) Health indicator long
description.
TYPE VARCHAR(16) Health indicator type.
Possible values are:
v ’THRESHOLD_UPPER’:
upper-bounded
threshold-based health
indicators.
v ’THRESHOLD_LOWER’:
lower-bounded
threshold-based health
indicators.
v ’STATE’: state-based health
indicators.
v ’COLLECTION_STATE’:
collection state-based
health indicators.
UNIT VARCHAR(1024) Unit of the health indicator
values and thresholds or Null
if not applicable.
CATEGORY VARCHAR(1024) Health indicator category.
FORMULA VARCHAR(512) Health indicator formula.
REFRESH_INTERVAL BIGINT Health indicator evaluation
interval in seconds.
HEALTH_HI_REC
HEALTH_HI_REC ( schema-version , indicator-id , dbname ,
recommendation-doc )
If the specified health indicator on the identified object is not in an alert state, an
error is returned (SQLSTATE 5U0ZZ).
schema-version
An input argument of type INTEGER that specifies the version ID of the
schema used to represent the XML document. The recommendation document
will only contain elements and attributes that were defined for that schema
version. Valid schema versions are defined in db2ApiDf.h, located in the
include subdirectory of the sqllib directory.
indicator-id
An input argument of type INTEGER that specifies the numeric identifier of
the health indicator for which recommendations are being requested. Valid
health indicator IDs are defined in sqlmon.h, located in the include
subdirectory of the sqllib directory.
dbname
An input argument of type VARCHAR(255) that specifies an alias name for the
database against which the health indicator entered an alert state, and when
object type is either DB2HEALTH_OBJTYPE_TS_CONTAINER,
DB2HEALTH_OBJTYPE_TABLESPACE, or DB2HEALTH_OBJTYPE_DATABASE. Specify NULL
otherwise.
object-type
An input argument of type INTEGER that specifies the type of object on which
the health indicator entered an alert state. Valid object types are defined in
sqlmon.h, located in the include subdirectory of the sqllib directory.
object-name
An input argument of type VARCHAR(255) that specifies the name of a table
space or table space container when the object type is set to
DB2HEALTH_OBJTYPE_TABLESPACE or DB2HEALTH_OBJTYPE_TS_CONTAINER. Specify
NULL if the object type is DB2HEALTH_OBJTYPE_DATABASE or
DB2HEALTH_OBJTYPE_DATABASE_MANAGER. In the case of a table space container,
the object name is specified as table_space_name.container_name.
dbpartitionnum
An input argument of type INTEGER that specifies the number of the database
partition on which the health indicator entered an alert state. Valid values are 0
to 999, -1 (which specifies the currently connected database partition), and -2
(which specifies all active database partitions). An active database partition is a
partition where the database is available for connection and use by
applications.
client-locale
An input argument of type VARCHAR(33) that specifies a client language
identifier. Use this parameter to specify the language in which
recommendations are to be returned. If no value is specified, ’En_US’ (English)
will be used. Note that if the message files for the specified locale are not
available on the server, ’En_US’ will be used as the default.
recommendation-doc
An output argument of type BLOB(2M) that contains the recommendation
document (XML), formatted according to the DB2 Health Recommendation
schema definition (see the XML schema DB2RecommendationSchema.xsd,
located in the misc subdirectory of the sqllib directory). The XML document is
HEALTH_TBS_HI
Returns health indicator information for table spaces from a health snapshot of
table spaces in a database.
Syntax
HEALTH_TBS_HI ( dbname , dbpartitionnum )
Authorization
Example
SELECT * FROM TABLE(HEALTH_TBS_HI(’’,-1)) AS T
11 record(s) selected.
Information returned
Table 91. Information returned by the HEALTH_TBS_HI table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TABLESPACE_NAME VARCHAR(128) tablespace_name - Table
space name
HI_ID BIGINT A number that uniquely
identifies the health indicator
in the snapshot data stream.
HI_VALUE SMALLINT The value of the health
indicator.
HI_TIMESTAMP TIMESTAMP The date and time that the
alert was generated.
HI_ALERT_STATE BIGINT The severity of the alert.
HI_ALERT_STATE_DETAIL VARCHAR(20) The text description of the
HI_ALERT_STATE column.
HI_FORMULA VARCHAR(2048) The formula used to calculate
the health indicator.
HI_ADDITIONAL_INFO VARCHAR(4096) Additional information about
the health indicator.
HEALTH_TBS_HI_HIS
The HEALTH_TBS_HI_HIS table function returns health indicator history
information for table spaces from a health snapshot of a database.
Syntax
Authorization
EXECUTE privilege on the HEALTH_TBS_HI_HIS table function.
Example
SELECT * FROM TABLE(HEALTH_TBS_HI_HIS(’’,-1)) AS T
22 record(s) selected.
Information returned
Table 92. Information returned by the HEALTH_TBS_HI_HIS table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TABLESPACE_NAME VARCHAR(128) tablespace_name - Table
space name
HI_ID BIGINT A number that uniquely
identifies the health indicator
in the snapshot data stream.
HI_TIMESTAMP TIMESTAMP The date and time that the
alert was generated.
HI_VALUE SMALLINT The value of the health
indicator.
HI_ALERT_STATE BIGINT The severity of the alert.
HI_ALERT_STATE_DETAIL VARCHAR(20) The text description of the
HI_ALERT_STATE column.
HI_FORMULA VARCHAR(2048) The formula used to calculate
the health indicator.
HI_ADDITIONAL_INFO VARCHAR(4096) Additional information about
the health indicator.
HEALTH_TBS_INFO
Returns table space information from a health snapshot of a database.
Syntax
HEALTH_TBS_INFO ( dbname , dbpartitionnum )
Authorization
Example
SELECT * FROM TABLE(HEALTH_TBS_INFO(’’,-1)) AS T
5 record(s) selected.
Information returned
Table 93. Information returned by the HEALTH_TBS_INFO table function
Description or
corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TABLESPACE_NAME VARCHAR(128) tablespace_name - Table
space name
ROLLED_UP_ALERT_STATE BIGINT The most severe alert state
captured by this snapshot.
VARCHAR(20) The text description of the
ROLLED_UP_ALERT_ ROLLED_UP_ALERT_STATE
STATE_DETAIL column.
MQSeries routines
MQPUBLISH
The MQPUBLISH function publishes data to MQSeries. For more details, visit
http://www.ibm.com/software/MQSeries.
The data type of the result is VARCHAR(1). The result of the function is ’1’ if
successful or ’0’ if unsuccessful.
Syntax
MQPUBLISH ( msg-data
publisher-service ,
service-policy ,
)
, topic
(1)
, correl-id
Notes:
1 The correl-id cannot be specified unless a service and a policy are also specified.
Function parameters
publisher-service
A string containing the logical MQSeries destination where the message is to
be sent. If specified, the publisher-service must refer to a publisher Service
Point defined in the DB2MQ.MQPUBSUB table that has a type value of ’P’ for
publisher service. If publisher-service is not specified, the
DB2.DEFAULT.PUBLISHER will be used. The maximum size of publisher-service
is 48 bytes.
service-policy
A string containing the MQSeries Service Policy to be used in handling of this
message. If specified, the service-policy must refer to a Policy defined in the
DB2MQ.MQPOLICY table. A Service Policy defines a set of quality of service
options that should be applied to this messaging operation. These options
include message priority and message persistence. If service-policy is not
specified, the default DB2.DEFAULT.POLICY will be used. The maximum size
of service-policy is 48 bytes.
msg-data
A string expression containing the data to be sent via MQSeries. The maximum
size for a VARCHAR string expression is 32 000 bytes and the maximum size
for a CLOB string expression is 1M bytes.
topic
A string expression containing the topic for the message publication. If no topic
is specified, none will be associated with the message. The maximum size of
topic is 40 bytes. Multiple topics can be specified in one string (up to 40
characters long). Each topic must be separated by a colon. For example,
″t1:t2:the third topic″ indicates that the message is associated with all three
topics: t1, t2, and ″the third topic″.
Examples
Example 1: This example publishes the string ″Testing 123″ to the default publisher
service (DB2.DEFAULT.PUBLISHER) using the default policy
(DB2.DEFAULT.POLICY). No correlation identifier or topic is specified for the
message.
VALUES MQPUBLISH(’Testing 123’)
Example 2: This example publishes the string ″Testing 345″ to the publisher service
″MYPUBLISHER″ under the topic ″TESTS″. The default policy is used and no
correlation identifier is specified.
VALUES MQPUBLISH(’MYPUBLISHER’,’Testing 345’, ’TESTS’)
Example 3: This example publishes the string ″Testing 678″ to the publisher service
″MYPUBLISHER″ using the policy ″MYPOLICY″ with a correlation identifier of
″TEST1″. The message is published with topic ″TESTS″.
VALUES MQPUBLISH(’MYPUBLISHER’,’MYPOLICY’,’Testing 678’,’TESTS’,’TEST1’)
Example 4: This example publishes the string ″Testing 901″ to the publisher service
″MYPUBLISHER″ under the topic ″TESTS″ using the default policy
(DB2.DEFAULT.POLICY) and no correlation identifier.
VALUES MQPUBLISH(’Testing 901’,’TESTS’)
MQREAD
The MQREAD function returns a message from the MQSeries location specified by
receive-service, using the quality of service policy defined in service-policy. Executing
this operation does not remove the message from the queue associated with
receive-service, but instead returns the message at the head of the queue.
The data type of the result is VARCHAR (32000). If no messages are available to be
returned, the result is the null value.
Syntax
MQREAD ( )
receive-service
, service-policy
Function parameters
receive-service
A string containing the logical MQSeries destination from where the message is
to be received. If specified, the receive-service must refer to a Service Point
defined in the DB2MQ.MQSERVICE table. A service point is a logical
end-point from where a message is sent or received. Service points definitions
Chapter 3. Supported routines and views 269
include the name of the MQSeries Queue Manager and Queue. If receive-service
is not specified, then the DB2.DEFAULT.SERVICE will be used. The maximum
size of receive-service is 48 bytes.
service-policy
A string containing the MQSeries Service Policy used in handling this message.
If specified, the service-policy must refer to a Policy defined in the
DB2MQ.MQPOLICY table. A Service Policy defines a set of quality of service
options that should be applied to this messaging operation. These options
include message priority and message persistence. If service-policy is not
specified, then the default DB2.DEFAULT.POLICY will be used. The maximum
size of service-policy is 48 bytes.
Examples
Example 1: This example reads the message at the head of the queue specified by
the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY).
VALUES MQREAD()
Example 2: This example reads the message at the head of the queue specified by
the service ″MYSERVICE″ using the default policy (DB2.DEFAULT.POLICY).
VALUES MQREAD(’MYSERVICE’)
Example 3: This example reads the message at the head of the queue specified by
the service ″MYSERVICE″, and using the policy ″MYPOLICY″.
VALUES MQREAD(’MYSERVICE’,’MYPOLICY’)
MQREADALL
The MQREADALL table function returns a table containing the messages and
message metadata from the MQSeries location specified by receive-service, using the
quality of service policy service-policy. Performing this operation does not remove
the messages from the queue associated with receive-service.
Syntax
MQREADALL ( )
receive-service num-rows
, service-policy
Authorization
Examples
Example 1: This example receives all the messages from the queue specified by the
default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). The messages and all the metadata are returned as a
table.
SELECT * FROM table (MQREADALL()) AS T
Example 2: This example receives all the messages from the head of the queue
specified by the service MYSERVICE, using the default policy
(DB2.DEFAULT.POLICY). Only the MSG and CORRELID columns are returned.
SELECT T.MSG, T.CORRELID FROM table (MQREADALL(’MYSERVICE’)) AS T
Example 3: This example reads the head of the queue specified by the default
service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). Only messages with a CORRELID of ’1234’ are returned.
All columns are returned.
SELECT * FROM table (MQREADALL()) AS T WHERE T.CORRELID = ’1234’
Example 4: This example receives the first 10 messages from the head of the queue
specified by the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). All columns are returned.
SELECT * FROM table (MQREADALL(10)) AS T
Information returned
Table 94. Information returned by the MQREADALL table function
Column name Data type Description
MSG VARCHAR(32000) Contains the contents of the
MQSeries message.
MQREADALLCLOB
The MQREADALLCLOB table function returns a table containing the messages
and message metadata from the MQSeries location specified by receive-service,
using the quality of service policy service-policy. Performing this operation does not
remove the messages from the queue associated with receive-service.
Syntax
MQREADALLCLOB
( )
receive-service num-rows
, service-policy
Authorization
Examples
Example 1: This example receives all the messages from the queue specified by the
default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). The messages and all the metadata are returned as a
table.
SELECT * FROM table (MQREADALLCLOB()) AS T
Example 2: This example receives all the messages from the head of the queue
specified by the service MYSERVICE, using the default policy
(DB2.DEFAULT.POLICY). Only the MSG and CORRELID columns are returned.
SELECT T.MSG, T.CORRELID FROM table (MQREADALLCLOB(’MYSERVICE’)) AS T
Example 3: This example reads the head of the queue specified by the default
service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). Only messages with a CORRELID of ’1234’ are returned.
All columns are returned.
SELECT * FROM table (MQREADALLCLOB()) AS T WHERE T.CORRELID = ’1234’
Example 4: This example receives the first 10 messages from the head of the queue
specified by the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). All columns are returned.
SELECT * FROM table (MQREADALLCLOB(10)) AS T
Information returned
Table 95. Information returned by the MQREADALLCLOB table function
Column name Data type Description
MSG CLOB(1M) Contains the contents of the
MQSeries message.
MQREADCLOB
The MQREADCLOB function returns a message from the MQSeries location
specified by receive-service, using the quality of service policy defined in
service-policy. Executing this operation does not remove the message from the
queue associated with receive-service, but instead returns the message at the head of
the queue.
Syntax
MQREADCLOB ( )
receive-service
, service-policy
Function parameters
receive-service
A string containing the logical MQSeries destination from where the message is
to be received. If specified, the receive-service must refer to a Service Point
defined in the DB2MQ.MQSERVICE table. A service point is a logical
end-point from where a message is sent or received. Service points definitions
Examples
Example 1: This example reads the message at the head of the queue specified by
the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY).
VALUES MQREADCLOB()
Example 2: This example reads the message at the head of the queue specified by
the service ″MYSERVICE″ using the default policy (DB2.DEFAULT.POLICY).
VALUES MQREADCLOB(’MYSERVICE’)
Example 3: This example reads the message at the head of the queue specified by
the service ″MYSERVICE″, and using the policy ″MYPOLICY″.
VALUES MQREADCLOB(’MYSERVICE’,’MYPOLICY’)
MQRECEIVE
The MQRECEIVE function returns a message from the MQSeries location specified
by receive-service, using the quality of service policy service-policy. Performing this
operation removes the message from the queue associated with receive-service. If the
correl-id is specified, then the first message with a matching correlation identifier
will be returned. If correl-id is not specified, then the message at the head of the
queue will be returned.
The data type of the result is VARCHAR (32000). If no messages are available to be
returned, the result is the null value.
Syntax
MQRECEIVE
( )
receive-service
, service-policy
, correl-id
Examples
Example 1: This example receives the message at the head of the queue specified
by the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY).
VALUES MQRECEIVE()
Example 2: This example receives the message at the head of the queue specified
by the service ″MYSERVICE″ using the default policy (DB2.DEFAULT.POLICY).
VALUES MQRECEIVE(’MYSERVICE’)
Example 3: This example receives the message at the head of the queue specified
by the service ″MYSERVICE″ using the policy ″MYPOLICY″.
VALUES MQRECEIVE(’MYSERVICE’,’MYPOLICY’)
Example 4: This example receives the first message with a correlation id that
matches ’1234’ from the head of the queue specified by the service ″MYSERVICE″
using the policy ″MYPOLICY″.
VALUES MQRECEIVE(’MYSERVICE’,’MYPOLICY’,’1234’)
MQRECEIVEALL
The MQRECEIVEALL table function returns a table containing the messages and
message metadata from the MQSeries location specified by receive-service, using the
quality of service policy service-policy. Performing this operation removes the
messages from the queue associated with receive-service.
Syntax
receive-service
, service-policy
, correl-id
)
num-rows
,
Authorization
Example 1: This example receives all the messages from the queue specified by the
default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). The messages and all the metadata are returned as a
table.
SELECT * FROM table (MQRECEIVEALL()) AS T
Example 2: This example receives all the messages from the head of the queue
specified by the service MYSERVICE, using the default policy
(DB2.DEFAULT.POLICY). Only the MSG and CORRELID columns are returned.
SELECT T.MSG, T.CORRELID FROM table (MQRECEIVEALL(’MYSERVICE’)) AS T
Example 3: This example receives all of the message from the head of the queue
specified by the service ″MYSERVICE″, using the policy ″MYPOLICY″. Only
messages with a CORRELID of ’1234’ are returned. Only the MSG and CORRELID
columns are returned.
SELECT T.MSG, T.CORRELID FROM table
(MQRECEIVEALL(’MYSERVICE’,’MYPOLICY’,’1234’)) AS T
Example 4: This example receives the first 10 messages from the head of the queue
specified by the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). All columns are returned.
SELECT * FROM table (MQRECEIVEALL(10)) AS T
Information returned
Table 96. Information returned by the MQRECEIVEALL table function
Column name Data type Description
MSG VARCHAR(32000) Contains the contents of the
MQSeries message.
CORRELID VARCHAR(24) Contains a correlation ID that
can be used to identify
messages. You can select a
message from the queue
using this identifier. In the
case of a request and
response scenario, the
correlation ID enables you to
associate a response with a
particular request.
TOPIC VARCHAR(40) Contains the topic with
which the message was
published, if available.
QNAME VARCHAR(48) Contains the name of the
queue where the message
was received.
MSGID CHAR(24) Contains the assigned unique
MQSeries identifier for this
message.
MSGFORMAT VARCHAR(8) Contains the format of the
message, as defined by
MQSeries. Typical strings
have an MQSTR format.
Syntax
MQRECEIVEALLCLOB (
receive-service
, service-policy
, correl-id
)
num-rows
,
Authorization
Examples
Example 1: This example receives all the messages from the queue specified by the
default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). The messages and all the metadata are returned as a
table.
SELECT * FROM table (MQRECEIVEALLCLOB()) AS T
Example 2: This example receives all the messages from the head of the queue
specified by the service MYSERVICE, using the default policy
(DB2.DEFAULT.POLICY). Only the MSG and CORRELID columns are returned.
SELECT T.MSG, T.CORRELID
FROM table (MQRECEIVEALLCLOB(’MYSERVICE’)) AS T
Example 3: This example receives all of the message from the head of the queue
specified by the service ″MYSERVICE″, using the policy ″MYPOLICY″. Only
messages with a CORRELID of ’1234’ are returned. Only the MSG and CORRELID
columns are returned.
SELECT T.MSG, T.CORRELID
FROM table (MQRECEIVEALLCLOB(’MYSERVICE’,’MYPOLICY’,’1234’)) AS T
Example 4: This example receives the first 10 messages from the head of the queue
specified by the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY). All columns are returned.
SELECT * FROM table (MQRECEIVEALLCLOB(10)) AS T
Information returned
Table 97. Information returned by the MQRECEIVEALLCLOB table function
Column name Data type Description
MSG CLOB(1M) Contains the contents of the
MQSeries message.
CORRELID VARCHAR(24) Contains a correlation ID that
can be used to identify
messages. You can select a
message from the queue
using this identifier. In the
case of a request and
response scenario, the
correlation ID enables you to
associate a response with a
particular request.
TOPIC VARCHAR(40) Contains the topic with
which the message was
published, if available.
QNAME VARCHAR(48) Contains the name of the
queue where the message
was received.
MQRECEIVECLOB
The MQRECEIVECLOB function returns a message from the MQSeries location
specified by receive-service, using the quality of service policy service-policy.
Performing this operation removes the message from the queue associated with
receive-service. If the correl-id is specified, the first message with a matching
correlation identifier will be returned. If correl-id is not specified, the message at the
head of the queue will be returned.
Syntax
MQRECEIVECLOB
( )
receive-service
, service-policy
, correl-id
Function paramters
receive-service
A string containing the logical MQSeries destination from which the message is
received. If specified, the receive-service must refer to a Service Point defined in
the DB2MQ.MQSERVICE table. A service point is a logical end-point from
which a message is sent or received. Service points definitions include the
name of the MQSeries Queue Manager and Queue. If receive-service is not
specified, the DB2.DEFAULT.SERVICE is used. The maximum size of
receive-service is 48 bytes.
service-policy
A string containing the MQSeries Service Policy to be used in the handling of
this message. If specified, the service-policy must refer to a policy defined in the
DB2MQ.MQPOLICY table. A service policy defines a set of quality of service
options that should be applied to this messaging operation. These options
include message priority and message persistence. If service-policy is not
specified, the default DB2.DEFAULT.POLICY is used. The maximum size of
service-policy is 48 bytes.
correl-id
A string containing an optional correlation identifier to be associated with this
Examples
Example 1: This example receives the message at the head of the queue specified
by the default service (DB2.DEFAULT.SERVICE), using the default policy
(DB2.DEFAULT.POLICY).
VALUES MQRECEIVECLOB()
Example 2: This example receives the message at the head of the queue specified
by the service ″MYSERVICE″ using the default policy (DB2.DEFAULT.POLICY).
VALUES MQRECEIVECLOB(’MYSERVICE’)
Example 3: This example receives the message at the head of the queue specified
by the service ″MYSERVICE″ using the policy ″MYPOLICY″.
VALUES MQRECEIVECLOB(’MYSERVICE’,’MYPOLICY’)
Example 4: This example receives the first message with a correlation ID that
matches ’1234’ from the head of the queue specified by the service ″MYSERVICE″
using the policy ″MYPOLICY″.
VALUES MQRECEIVECLOB(’MYSERVICE’,MYPOLICY’,’1234’)
MQSEND
The MQSEND function sends the data contained in msg-data to the MQSeries
location specified by send-service, using the quality of service policy defined by
service-policy. An optional user-defined message correlation identifier can be
specified using correl-id.
The data type of the result is VARCHAR(1). The result of the function is ’1’ if
successful or ’0’ if unsuccessful.
Syntax
MQSEND ( msg-data
send-service ,
service-policy ,
)
(1)
, correl-id
Notes:
1 The correl-id cannot be specified unless a service and a policy are also specified.
Function parameters
msg-data
A string expression containing the data to be sent via MQSeries. The maximum
Examples
Example 1: This example sends the string ″Testing 123″ to the default service
(DB2.DEFAULT.SERVICE), using the default policy (DB2.DEFAULT.POLICY), with
no correlation identifier.
VALUES MQSEND(’Testing 123’)
Example 2: This example sends the string ″Testing 345″ to the service
″MYSERVICE″, using the policy ″MYPOLICY″, with no correlation identifier.
VALUES MQSEND(’MYSERVICE’,’MYPOLICY’,’Testing 345’)
Example 3: This example sends the string ″Testing 678″ to the service
″MYSERVICE″, using the policy ″MYPOLICY″, with correlation identifier ″TEST3″.
VALUES MQSEND(’MYSERVICE’,’MYPOLICY’,’Testing 678’,’TEST3’)
Example 4: This example sends the string ″Testing 901″ to the service
″MYSERVICE″, using the default policy (DB2.DEFAULT.POLICY), and no
correlation identifier.
VALUES MQSEND(’MYSERVICE’,’Testing 901’)
MQSUBSCRIBE
The MQSUBSCRIBE function is used to register interest in MQSeries messages
published on a specified topic. Successful execution of this function causes the
publish and subscribe server to forward messages matching the topic to the service
point defined by subscriber-service. The subscriber-service specifies a logical
destination for messages that match the specified topic. Messages that match topic
are placed on the queue defined by subscriber-service, and can be read or received
The data type of the result is VARCHAR(1). The result of the function is ’1’ if
successful or ’0’ if unsuccessful.
Syntax
MQSUBSCRIBE ( topic )
subscriber-service ,
service-policy ,
Function parameters
subscriber-service
A string containing the logical MQSeries subscription point to where messages
matching topic will be sent. If specified, the subscriber-service must refer to a
Subscribers Service Point defined in the DB2MQ.MQPUBSUB table that has a
type value of ’S’ for publisher service. If subscriber-service is not specified, then
the DB2.DEFAULT.SUBSCRIBER will be used instead. The maximum size of
subscriber-service is 48 bytes.
service-policy
A string containing the MQSeries Service Policy to be used in handling the
message. If specified, the service-policy must refer to a Policy defined in the
DB2MQ.MQPOLICY table. A Service Policy defines a set of quality of service
options to be applied to this messaging operation. These options include
message priority and message persistence. If service-policy is not specified, then
the default DB2.DEFAULT.POLICY will be used instead. The maximum size of
service-policy is 48 bytes.
topic
A string defining the types of messages to receive. Only messages published
with the specified topics will be received by this subscription. Multiple
subscriptions can coexist. The maximum size of topic is 40 bytes. Multiple
topics can be specified in one string (up to 40 bytes long). Each topic must be
separated by a colon. For example, ″t1:t2:the third topic″ indicates that the
message is associated with all three topics: t1, t2, and ″the third topic″.
Examples
The data type of the result is VARCHAR(1). The result of the function is ’1’ if
successful or ’0’ if unsuccessful.
Syntax
MQUNSUBSCRIBE
( topic )
subscriber-service ,
service-policy ,
Function parameters
subscriber-service
If specified, the subscriber-service must refer to a Subscribers Service Point
defined in the DB2MQ.MQPUBSUB table that has a type value of ’S’ for
publisher service. If subscriber-service is not specified, then the
DB2.DEFAULT.SUBSCRIBER will be used instead. The maximum size of
subscriber-service is 48 bytes.
service-policy
If specified, the service-policy must refer to a Policy defined in the
DB2MQ.MQPOLICY table. A Service Policy defines a set of quality of service
options to be applied to this messaging operation. If service-policy is not
specified, then the default DB2.DEFAULT.POLICY will be used. The maximum
size of service-policy is 48 bytes.
topic
A string specifying the subject of messages that are not to be received. The
maximum size of topic is 40 bytes. Multiple topics can be specified in one
string (up to 40 bytes long). Each topic must be separated by a colon. For
example, ″t1:t2:the third topic″ indicates that the message is associated with all
three topics: t1, t2, and ″the third topic″.
Examples
AUTH_LIST_AUTHORITIES_FOR_AUTHID
The AUTH_LIST_AUTHORITIES_FOR_AUTHID table function returns all
authorities held by the authorization ID, either found in the database configuration
file or granted to an authorization ID directly or indirectly through a group or a
role.
Syntax
AUTH_LIST_AUTHORITIES_FOR_AUTHID ( authid , authidtype )
Authorization
Information returned
Table 98. The information returned for AUTH_LIST_AUTHORITIES_FOR_AUTHID
Column Name Data Type Description
AUTHORITY VARCHAR(128) Authority held by the authorization ID
D_USER CHAR(1) Authority granted directly to the authid, when the authidtype is a
user (U). If the authidtype is a group (G) or a role (R), then the value
is not applicable (’*’).
v N = Not held
v Y= Held
v * = Not applicable
Example
Consider user ALICE who by default holds BIND, CONNECT, CREATETAB and
IMPLICIT_SCHEMA privileges through special group PUBLIC. ALICE is a member
of a group ADMIN1 who has the following system authorities: SYSADM,
SYSCTRL and SYSMAINT. She is also a member of group ADMIN2 who has
DBADM authority. Also, ALICE has been granted DBADM and SECADM database
Example 1: Retrieve all authorities user ALICE has granted either directly to her or
indirectly through a group, PUBLIC or a role.
SELECT AUTHORITY, D_USER, D_GROUP, D_PUBLIC, ROLE_USER, ROLE_GROUP, ROLE_PUBLIC, D_ROLE
FROM TABLE (SYSPROC.AUTH_LIST_AUTHORITIES_FOR_AUTHID (’ALICE’, ’U’) ) AS T
ORDER BY AUTHORITY
Example 2: Retrieve all authorities group ADMIN1 has granted either directly to it
or indirectly through PUBLIC or a role.
SELECT AUTHORITY, D_USER, D_GROUP, D_PUBLIC, ROLE_USER, ROLE_GROUP, ROLE_PUBLIC, D_ROLE
FROM TABLE (SYSPROC.AUTH_LIST_AUTHORITIES_FOR_AUTHID (’ADMIN1’, ’G’) ) AS T
ORDER BY AUTHORITY
Example 3: Retrieve all authorities special group PUBLIC has granted either
directly to it or indirectly through a role
SELECT AUTHORITY, D_USER, D_GROUP, D_PUBLIC, ROLE_USER, ROLE_GROUP, ROLE_PUBLIC, D_ROLE
FROM TABLE (SYSPROC.AUTH_LIST_AUTHORITIES_FOR_AUTHID (’PUBLIC’, ’G’) ) AS T
ORDER BY AUTHORITY
Usage Notes
Syntax
AUTH_LIST_GROUPS_FOR_AUTHID ( authid )
Authorization
Example
2 record(s) selected.
Usage notes
Group information returned might be different than expected for the following
reasons:
v In a Windows Active Directory environment, the database manager:
– supports one level of group nesting within a local group, except the nesting
of a domain local group within a local group. For example, if authid belongs
to the global group G1, and G1 belongs to the local group L1, the local group
L1 is returned as the group for authid. However, if authid belongs to the
domain local group DL1, and DL1 belongs to the local group L1, no group
information is returned for authid.
– does not support any nesting of global groups. For example, if authid belongs
to the global G2, and G2 belongs to the global G3, only G2 is returned as the
group for authid.
v The registry variable DB2_GRP_LOOKUP specifies which Windows security
mechanism is used to enumerate the groups to which a user belongs.
v For an authorization ID that belongs to a particular domain, if the domain is not
specified as part of the authid, and both a local and domain authid exist with the
same name, the groups for the local authorization ID is returned.
Information returned
Table 99. Information returned by the AUTH_LIST_GROUPS_FOR_AUTHID table function
Column name Data type Description
GROUP VARCHAR(128) The group to which the
authorization ID belongs.
Syntax
AUTH_LIST_ROLES_FOR_AUTHID ( authid , authidtype )
Authorization
Information returned
Table 100. The result sets for AUTH_LIST_ROLES_FOR_AUTHID
Column Name Data Type Description
GRANTOR VARCHAR(128) Grantor of the role.
GRANTORTYPE CHAR(1) Type of grantor:
v U = Grantor is an individual user
GRANTEE VARCHAR(128) User granted the role.
GRANTEETYPE CHAR(1) Type of grantee:
v G = Grantee is a group
v R= Grantee is a role
v U= Grantee is a user
ROLENAME VARCHAR(128) Name of the role granted to the authorization ID directly or
indirectly through a group or another role.
CREATE_TIME TIMESTAMP Time when role was created.
ADMIN CHAR(1) Privilege to grant the role to, revoke the role from, or to
comment on a role:
v N = Not held
v Y= Held
Example
Consider granting role INTERN to role DOCTOR and role DOCTOR to role
SPECIALIST, then grant role SPECIALIST to user ALICE. ALICE belongs to group
HOSPITAL and role EMPLOYEE is granted to group HOSPITAL. ALICE also
belongs to special group PUBLIC and role PATIENTS is granted to PUBLIC.
5 record(s) selected.
1 record(s) selected.
2 record(s) selected.
1 record(s) selected.
Usage notes
Authorization
Example
Retrieve all authorization IDs that have been granted privileges or authorities,
along with their types.
SELECT * FROM SYSIBMADM.AUTHORIZATIONIDS
3 record(s) selected.
Information returned
Table 101. Information returned by the AUTHORIZATIONIDS administrative view
Column name Data type Description
AUTHID VARCHAR(128) Authorization ID that has
been explicitly granted
privileges or authorities.
AUTHIDTYPE CHAR(1) Authorization ID type:
v U: user
v R: role
v G: group
Authorization
Example
Information returned
Table 102. Information returned by the OBJECTOWNERS administrative view
Column name Data type Description
OWNER VARCHAR(128) Authorization ID that owns
this object.
OWNERTYPE VARCHAR(1) Authorization ID type:
v U: user
OBJECTNAME VARCHAR(128) Database object name.
OBJECTSCHEMA VARCHAR(128) Database object schema.
OBJECTTYPE VARCHAR(24) Database object type.
Authorization
Example
Retrieve the privilege granted along with the object name, schema and type, for all
authorization IDs.
SELECT AUTHID, PRIVILEGE, OBJECTNAME, OBJECTSCHEMA, OBJECTTYPE
FROM SYSIBMADM.PRIVILEGES
Information returned
Table 103. Information returned by the PRIVILEGES administrative view
Column name Data type Description
AUTHID VARCHAR(128) Authorization ID that has
been explicitly granted this
privilege.
AUTHIDTYPE CHAR(1) Authorization ID type:
v U: user
v R: role
v G: group
PRIVILEGE VARCHAR(11) Privilege that has been
explicitly granted to this
authorization ID.
GRANTABLE VARCHAR(1) Indicates if the privilege is
grantable:
v Y: Grantable
v N: Not grantable
OBJECTNAME VARCHAR(128) Database object name.
OBJECTSCHEMA VARCHAR(128) Database object schema.
OBJECTTYPE VARCHAR(24) Database object type.
Example
Information returned
Table 104. Information returned by the APPL_PERFORMANCE administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AUTHID VARCHAR(128) auth_id - Authorization ID
APPL_NAME VARCHAR(256) appl_name - Application name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
PERCENT_ROWS_SELECTED DECIMAL(5,2) The percent of rows read from disk
that were actually returned to the
application.
DBPARTITIONNUM SMALLINT The database partition from which
the data was retrieved for this row.
Authorization
v SELECT or CONTROL privilege on the APPLICATIONS and SNAPAPPL_INFO
administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority which is required to
access snapshot monitor data.
Example
Example 1: List information for all the active applications in the single-partitioned
database SAMPLE.
SELECT AGENT_ID, SUBSTR(APPL_NAME,1,10) AS APPL_NAME, AUTHID,
APPL_STATUS FROM SYSIBMADM.APPLICATIONS WHERE DB_NAME = ’SAMPLE’
1 record(s) selected.
Example 2: List the number of agents per application on database partition 0 for the
multi-partition database SAMPLE.
SELECT SUBSTR(APPL_NAME, 1, 10) AS APPL_NAME, COUNT(*) AS NUM
FROM SYSIBMADM.APPLICATIONS WHERE DBPARTITIONNUM = 0
AND DB_NAME = ’SAMPLE’ GROUP BY APPL_NAME
2 record(s) selected.
Usage notes
The view does not support the GLOBAL syntax available from the CLP. However,
aggregation can be done using SQL aggregation functions as data from all database
partitions is returned from the view.
Information returned
Table 105. Information returned by the APPLICATIONS administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
CLIENT_DB_ALIAS VARCHAR(128) client_db_alias - Database alias
used by application
DB_NAME VARCHAR(128) db_name - Database name
Authorization
v SELECT or CONTROL privilege on the BP_HITRATIO and SNAPBP
administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Usage notes
The ratio of physical reads to logical reads gives the hit ratio for the bufferpool.
The lower the hit ratio, the more the data is being read from disk rather than the
cached buffer pool which can be a more costly operation.
Information returned
Table 106. Information returned by the BP_HITRATIO administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP Timestamp when the report was
requested.
DB_NAME VARCHAR(128) db_name - Database name
BP_NAME VARCHAR(128) bp_name - Buffer pool name
TOTAL_LOGICAL_READS BIGINT Total logical reads (index, XDA and
data) in the bufferpool.
TOTAL_PHYSICAL_READS BIGINT Total physical reads (index, XDA
and data) in the bufferpool.
TOTAL_HIT_RATIO_PERCENT DECIMAL(5,2) Total hit ratio (index, XDA and
data reads).
DATA_LOGICAL_READS BIGINT pool_data_l_reads - Buffer pool
data logical reads
DATA_PHYSICAL_READS BIGINT pool_data_p_reads - Buffer pool
data physical reads
DATA_HIT_RATIO_PERCENT DECIMAL(5,2) Data hit ratio.
INDEX_LOGICAL_READS BIGINT pool_index_l_reads - Buffer pool
index logical reads
Authorization
v SELECT or CONTROL privilege on the BP_READ_IO and SNAPBP
administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority are also required to
access snapshot monitor data.
Example
Retrieve total physical reads and average read time for all bufferpools on all
partitions of the currently connected database.
SELECT SUBSTR(BP_NAME, 1, 15) AS BP_NAME, TOTAL_PHYSICAL_READS,
AVERAGE_READ_TIME_MS, DBPARTITIONNUM
FROM SYSIBMADM.BP_READ_IO ORDER BY DBPARTITIONNUM
10 record(s) selected.
Authorization
v SELECT or CONTROL privilege on the BP_WRITE_IO and SNAPBP
administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Example
Retrieve total writes and average write time for all bufferpools on all database
partitions of the currently connected database.
SELECT SUBSTR(BP_NAME, 1, 15) AS BP_NAME, TOTAL_WRITES,
AVERAGE_WRITE_TIME_MS, DBPARTITIONNUM
FROM SYSIBMADM.BP_WRITE_IO ORDER BY DBPARTITIONNUM
11 record(s) selected.
Information returned
Table 108. Information returned by the BP_WRITE_IO administrative view
Description or
corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time the
report was generated.
BP_NAME VARCHAR(128) bp_name - Buffer pool
name
TOTAL_WRITES BIGINT Total writes.
AVERAGE_WRITE_TIME_MS BIGINT Average write time in
milliseconds.
TOTAL_ASYNC_WRITES BIGINT Total asynchronous
writes.
Authorization
v SELECT or CONTROL privilege on CONTAINER_UTILIZATION and
SNAPCONTAINER administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority (required to access
snapshot monitor data).
Example
Retrieve a list of all table spaces containers in the connected single partition
database, including information on total and usable pages as well as their
accessibility status.
SELECT SUBSTR(TBSP_NAME,1,20) AS TBSP_NAME, INT(TBSP_ID) AS TBSP_ID,
SUBSTR(CONTAINER_NAME,1,45) AS CONTAINER_NAME, INT(CONTAINER_ID)
AS CONTAINER_ID, CONTAINER_TYPE, INT(TOTAL_PAGES) AS TOTAL_PAGES,
INT(USABLE_PAGES) AS USABLE_PAGES, ACCESSIBLE
FROM SYSIBMADM.CONTAINER_UTILIZATION
5 record(s) selected.
Information returned
Authorization
v SELECT or CONTROL privilege on the LOCKS_HELD, SNAPLOCK and
SNAPAPPL_INFO administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Example
Example 1: List the total number of locks held by each table in the database
SAMPLE.
SELECT TABSCHEMA, TABNAME, COUNT(*) AS NUMBER_OF_LOCKS_HELD
FROM SYSIBMADM.LOCKS_HELD WHERE DB_NAME = ’SAMPLE’
GROUP BY DBPARTITIONNUM, TABSCHEMA, TABNAME
Example 2: List all the locks that have not escalated in the currently connected
database, SAMPLE.
SELECT AGENT_ID, TABSCHEMA, TABNAME, LOCK_OBJECT_TYPE, LOCK_MODE,
LOCK_STATUS FROM SYSIBMADM.LOCKS_HELD WHERE LOCK_ESCALATION = 0
AND DBPARTITIONNUM = 0
Example 3: List lock information for the locks that are currently held by the
application with agent ID 310.
SELECT TABSCHEMA, TABNAME, LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_STATUS,
LOCK_ESCALATION FROM SYSIBMADM.LOCKS_HELD WHERE AGENT_ID = 310
Information returned
Table 110. Information returned by the LOCKS_HELD administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP Date and time the report was
generated.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
APPL_NAME VARCHAR(256) appl_name - Application name
AUTHID VARCHAR(128) auth_id - Authorization ID
TBSP_NAME VARCHAR(128) tablespace_name - Table space
name
TABSCHEMA VARCHAR(128) table_schema - Table schema name
TABNAME VARCHAR(128) table_name - Table name
TAB_FILE_ID BIGINT table_file_id - Table file
identification
Authorization
v SELECT or CONTROL privilege on the LOCKWAITS, SNAPAPPL_INFO and
SNAPLOCKWAIT administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Examples
Example 1: List information for all the lock waits for application with agent ID 89.
SELECT SUBSTR(TABSCHEMA,1,8) AS TABSCHEMA, SUBSTR(TABNAME,1,15) AS TABNAME,
LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_MODE_REQUESTED, AGENT_ID_HOLDING_LK
FROM SYSIBMADM.LOCKWAITS WHERE AGENT_ID = 89
1 record(s) selected.
Example 2: List the total number of outstanding lock requests per table in the
database SAMPLE. By sorting the output by number of requests, tables with the
highest contention can be identified.
SELECT SUBSTR(TABSCHEMA,1,8) AS TABSCHEMA, SUBSTR(TABNAME, 1, 15)
AS TABNAME, COUNT(*) AS NUM_OF_LOCK_REQUESTS_WAITING,
DBPARTITIONNUM
3 record(s) selected.
Information returned
Table 111. Information returned by the LOCKWAITS administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP Date and time the report was
generated.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
APPL_NAME VARCHAR(256) appl_name - Application name
AUTHID VARCHAR(128) auth_id - Authorization ID
TBSP_NAME VARCHAR(128) tablespace_name - Table space
name
TABSCHEMA VARCHAR(128) table_schema - Table schema name
TABNAME VARCHAR(128) table_name - Table name
SUBSECTION_NUMBER BIGINT ss_number - Subsection number
Authorization
v SELECT or CONTROL privilege on the LOG_UTILIZATION and SNAPDB
administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Example
List the log utilization for the currently connected database, SAMPLE.
SELECT * FROM SYSIBMADM.LOG_UTILIZATION
Usage note
Information returned
Table 112. Information returned by the LOG_UTILIZATION administrative view
Description or corresponding
Column name Data type monitor element
DB_NAME VARCHAR(128) db_name - Database name
LOG_UTILIZATION_PERCENT DECIMAL(5,2) Percent utilization of total log
space.
TOTAL_LOG_USED_KB BIGINT total_log_used - Total log space
used. This interface returns the
value in KB.
TOTAL_LOG_AVAILABLE_KB BIGINT total_log_available - Total log
available. This interface returns the
value in KB.
Authorization
v SELECT or CONTROL privilege on the LONG_RUNNING_SQL, SNAPSTMT,
SNAPAPPL_INFO, and SNAPAPPL administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Example
Retrieve a report on long running SQL statements in the currently connected
database.
SELECT SUBSTR(STMT_TEXT, 1, 50) AS STMT_TEXT, AGENT_ID,
ELAPSED_TIME_MIN, APPL_STATUS, DBPARTITIONNUM
FROM SYSIBMADM.LONG_RUNNING_SQL ORDER BY DBPARTITIONNUM
Usage note
This view can be used to identify long-running SQL statements in the database.
You can look at the currently running queries to see which statements are the
longest running and the current status of the query. Further investigation can be
done of the application containing the SQL statement, using agent ID as the unique
identifier. If executing a long time and waiting on a lock, you might want to dig
deeper using the LOCKWAITS or LOCKS_HELD administrative views. If “waiting
on User”, this means that the DB2 server is not doing anything but rather is
Information returned
Table 113. Information returned by the LONG_RUNNING_SQL administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP Time the report was generated.
ELAPSED_TIME_MIN INTEGER Elapsed time of the statement in
minutes.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
APPL_NAME VARCHAR(256) appl_name - Application name
APPL_STATUS VARCHAR(22) appl_status - Application status.
This interface returns a text
identifier based on the defines in
sqlmon.h, and is one of:
v BACKUP
v COMMIT_ACT
v COMP
v CONNECTED
v CONNECTPEND
v CREATE_DB
v DECOUPLED
v DISCONNECTPEND
v INTR
v IOERROR_WAIT
v LOAD
v LOCKWAIT
v QUIESCE_TABLESPACE
v RECOMP
v REMOTE_RQST
v RESTART
v RESTORE
v ROLLBACK_ACT
v ROLLBACK_TO_SAVEPOINT
v TEND
v THABRT
v THCOMT
v TPREP
v UNLOAD
v UOWEXEC
v UOWWAIT
v WAITFOR_REMOTE
AUTHID VARCHAR(128) auth_id - Authorization ID
INBOUND_COMM_ADDRESS VARCHAR(32) inbound_comm_address - Inbound
communication address
STMT_TEXT CLOB(16 M) stmt_text - SQL statement text
Authorization
v SELECT or CONTROL privilege on the QUERY_PREP_COST and
SNAPDYN_SQL administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Example
Retrieve a report on the queries with the highest percentage of time spent on
preparing.
SELECT NUM_EXECUTIONS, AVERAGE_EXECUTION_TIME_S, PREP_TIME_PERCENT,
SUBSTR(STMT_TEXT, 1, 30) AS STMT_TEXT, DBPARTITIONNUM
FROM SYSIBMADM.QUERY_PREP_COST ORDER BY PREP_TIME_PERCENT
1 record(s) selected.
Usage notes
When selecting from the view, an order by clause can be used to identify queries
with the highest prep cost. You can examine this view to see how frequently a
query is run as well as the average execution time for each of these queries. If the
time it takes to compile and optimize a query is almost as long as it takes for the
query to execute, you might want to look at the optimization class that you are
using. Lowering the optimization class might make the query complete
optimization more rapidly and therefore return a result sooner. However, if a
query takes a significant amount of time to prepare yet is executed thousands of
times (without being prepared again) then the optimization class might not be an
issue.
This administrative view allows you to retrieve agent logical data group
application snapshot information for the currently connected database.
Refer to Table 115 on page 320 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAGENT administrative view and
EXECUTE privilege on the SNAP_GET_AGENT table function.
Example
Retrieve all application snapshot information for the currently connected database
from the agent logical data group.
SELECT * FROM SYSIBMADM.SNAPAGENT
Refer to Table 115 on page 320 for a complete list of information that can be
returned.
Syntax
SNAP_GET_AGENT ( dbname )
, dbpartitionnum
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_AGENT table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_AGENT table function.
Example
Retrieve all application snapshot information for all applications in all active
databases.
SELECT * FROM TABLE(SNAP_GET_AGENT(CAST(NULL AS VARCHAR(128)), -1)) AS T
6 record(s) selected.
Information returned
Table 115. Information returned by the SNAPAGENT administrative view and the
SNAP_GET_AGENT table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
AGENT_PID BIGINT agent_pid - Engine dispatchable
unit (EDU)
This administrative view allows you to retrieve the memory_pool logical data
group snapshot information about memory usage at the agent level for the
currently connected database.
Refer to Table 116 on page 323 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAGENT_MEMORY_POOL
administrative view and EXECUTE privilege on the
SNAP_GET_AGENT_MEMORY_POOL table function.
Example
9 record(s) selected.
Refer to Table 116 on page 323 for a complete list of information that can be
returned.
Syntax
SNAP_GET_AGENT_MEMORY_POOL ( dbname )
, dbpartitionnum
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_AGENT_MEMORY_POOL table function takes a snapshot for the
currently connected database and database partition number.
Example
Retrieve a list of memory pools and their current size for all databases.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, AGENT_ID, POOL_ID, POOL_CUR_SIZE
FROM TABLE(SNAP_GET_AGENT_MEMORY_POOL(CAST (NULL AS VARCHAR(128)), -1))
AS T
18 record(s) selected.
Information returned
Table 116. Information returned by the SNAPAGENT_MEMORY_POOL administrative view
and the SNAP_GET_AGENT_MEMORY_POOL table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
AGENT_PID BIGINT agent_pid - Engine dispatchable
unit (EDU)
This administrative view allows you to retrieve appl_info logical data group
snapshot information for the currently connected database.
Refer to Table 117 on page 327 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAPPL_INFO administrative view
and EXECUTE privilege on the SNAP_GET_APPL_INFO_V95 table function.
Example
2 record(s) selected.
Refer to Table 117 on page 327 for a complete list of information that can be
returned.
Syntax
SNAP_GET_APPL_INFO_V95 ( dbname )
, dbpartitionnum
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_APPL_INFO_V95 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_APPL_INFO_V95 table function.
Examples
4 record(s) selected.
The following shows what you obtain when you SELECT from the result of the
table function.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, AUTHORITY_LVL
FROM TABLE(SNAP_GET_APPL_INFO_V95(CAST(NULL AS VARCHAR(128)),-1)) AS T
3 record(s) selected.
Information returned
Table 117. Information returned by the SNAPAPPL_INFO administrative view and the
SNAP_GET_APPL_INFO_V95 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
This administrative view allows you to retrieve appl logical data group snapshot
information for the currently connected database.
Refer to Table 118 on page 334 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAPPL administrative view and
EXECUTE privilege on the SNAP_GET_APPL_V95 table function.
Example
Retrieve details on rows read and written for each application in the connected
database.
1 record(s) selected.
Refer to Table 118 on page 334 for a complete list of information that can be
returned.
Syntax
SNAP_GET_APPL_V95 ( dbname )
, dbpartitionnum
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
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_APPL_V95 table function.
Example
Retrieve details on rows read and written for each application for all active
databases.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, AGENT_ID, ROWS_READ, ROWS_WRITTEN
FROM TABLE (SNAP_GET_APPL_V95(CAST(NULL AS VARCHAR(128)),-1)) AS T
Information returned
Table 118. Information returned by the SNAPAPPL administrative view and the
SNAP_GET_APPL_V95 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
UOW_LOG_SPACE_USED BIGINT uow_log_space_used - Unit of
work log space used
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
INACT_STMTHIST_SZ BIGINT stmt_history_list_size - Statement
history list size
POOL_DATA_L_READS BIGINT pool_data_l_reads - Buffer pool
data logical reads
POOL_DATA_P_READS BIGINT pool_data_p_reads - Buffer pool
data physical reads
POOL_DATA_WRITES BIGINT pool_data_writes - Buffer pool data
writes
POOL_INDEX_L_READS BIGINT pool_index_l_reads - Buffer pool
index logical reads
POOL_INDEX_P_READS BIGINT pool_index_p_reads - Buffer pool
index physical reads
This administrative view allows you to retrieve bufferpool logical group snapshot
information for the currently connected database.
Refer to Table 119 on page 342 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPBP administrative view and
EXECUTE privilege on the SNAP_GET_BP_V95 table function.
Example
Retrieve data and index writes for all the bufferpools of the currently connected
database.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME,SUBSTR(BP_NAME,1,15)
AS BP_NAME,POOL_DATA_WRITES,POOL_INDEX_WRITES
FROM SYSIBMADM.SNAPBP
5 record(s) selected
Syntax
SNAP_GET_BP_V95 ( dbname )
, dbpartitionnum
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_BP_V95 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_BP_V95 table function.
Example
Retrieve total physical and logical reads for all bufferpools for all active databases
for the currently connected database partition.
SELECT SUBSTR(T.DB_NAME,1,10) AS DB_NAME,
SUBSTR(T.BP_NAME,1,20) AS BP_NAME,
(T.POOL_DATA_L_READS+T.POOL_INDEX_L_READS) AS TOTAL_LOGICAL_READS,
(T.POOL_DATA_P_READS+T.POOL_INDEX_P_READS) AS TOTAL_PHYSICAL_READS,
T.DBPARTITIONNUM
FROM TABLE(SNAP_GET_BP_V95(CAST(NULL AS VARCHAR(128)), -1)) AS T
3 record(s) selected.
Information returned
Table 119. Information returned by the SNAPBP administrative view and the
SNAP_GET_BP_V95 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
BP_NAME VARCHAR(128) bp_name - Buffer pool name
DB_NAME VARCHAR(128) db_name - Database name
DB_PATH VARCHAR(1024) db_path - Database path
INPUT_DB_ALIAS VARCHAR(128) input_db_alias - Input database
alias
POOL_DATA_L_READS BIGINT pool_data_l_reads - Buffer pool
data logical reads
POOL_DATA_P_READS BIGINT pool_data_p_reads - Buffer pool
data physical reads
POOL_DATA_WRITES BIGINT pool_data_writes - Buffer pool data
writes
POOL_INDEX_L_READS BIGINT pool_index_l_reads - Buffer pool
index logical reads
POOL_INDEX_P_READS BIGINT pool_index_p_reads - Buffer pool
index physical reads
POOL_INDEX_WRITES BIGINT pool_index_writes - Buffer pool
index writes
POOL_XDA_L_READS BIGINT pool_xda_l_reads - Buffer Pool
XDA Data Logical Reads
POOL_XDA_P_READS BIGINT pool_xda_p_reads - Buffer Pool
XDA Data Physical Reads
POOL_XDA_WRITES BIGINT pool_xda_writes - Buffer Pool XDA
Data Writes
POOL_READ_TIME BIGINT pool_read_time - Total buffer pool
physical read time
POOL_WRITE_TIME BIGINT pool_write_time - Total buffer pool
physical write time
POOL_ASYNC_DATA_READS BIGINT pool_async_data_reads - Buffer
pool asynchronous data reads
POOL_ASYNC_DATA_WRITES BIGINT pool_async_data_writes - Buffer
pool asynchronous data writes
Refer to Table 120 on page 347 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPBP_PART administrative view and
EXECUTE privilege on the SNAP_GET_BP_PART table function.
Example
Refer to Table 120 on page 347 for a complete list of information that can be
returned.
Syntax
SNAP_GET_BP_PART ( dbname )
, dbpartitionnum
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_BP_PART table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_BP_PART table function.
Example
Retrieve data for all bufferpools for all active databases when connected to the
SAMPLE database.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, SUBSTR(BP_NAME,1,15) AS BP_NAME,
BP_CUR_BUFFSZ, BP_NEW_BUFFSZ, BP_PAGES_LEFT_TO_REMOVE, BP_TBSP_USE_COUNT
FROM TABLE(SNAP_GET_BP_PART(CAST(NULL AS VARCHAR(128)),-1)) AS T
...
...
Refer to Table 121 on page 350 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPCONTAINER administrative view
and EXECUTE privilege on the SNAP_GET_CONTAINER_V91 table function.
Retrieve details for the table space containers for all database partitions for the
currently connected database.
SELECT SNAPSHOT_TIMESTAMP, SUBSTR(TBSP_NAME, 1, 15) AS TBSP_NAME,
TBSP_ID, SUBSTR(CONTAINER_NAME, 1, 20) AS CONTAINER_NAME,
CONTAINER_ID, CONTAINER_TYPE, ACCESSIBLE, DBPARTITIONNUM
FROM SYSIBMADM.SNAPCONTAINER ORDER BY DBPARTITIONNUM
Refer to Table 121 on page 350 for a complete list of information that can be
returned.
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_CONTAINER_V91 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_CONTAINER_V91 table function.
Example
Retrieve details for the table space containers on the currently connected database
on the currently connected database partition.
SELECT SNAPSHOT_TIMESTAMP, TBSP_NAME, TBSP_ID, CONTAINER_NAME,
CONTAINER_ID, CONTAINER_TYPE, ACCESSIBLE
FROM TABLE(SNAP_GET_CONTAINER_V91(’’,-1)) AS T
Information returned
This administrative view allows you to retrieve snapshot information from the
dbase logical group for the currently connected database.
Refer to Table 122 on page 354 for a complete list of information that is returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDB administrative view and
EXECUTE privilege on the SNAP_GET_DB_V95 table function.
Examples
Retrieve the status, platform, location, and connect time for all database partitions
of the currently connected database.
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
3 record(s) selected.
This routine can be used by calling the following on the command line:
SELECT TOTAL_OLAP_FUNCS, OLAP_FUNC_OVERFLOWS, ACTIVE_OLAP_FUNCS
FROM SYSIBMADM.SNAPDB
1 record(s) selected.
1 record(s) selected.
Refer to Table 122 on page 354 for a complete list of information that is returned.
Syntax
SNAP_GET_DB_V95 ( dbname )
, dbpartitionnum
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_DB_V95 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DB_V95 table function.
Examples
Example 1: Retrieve the status, platform, location, and connect time as an aggregate
view across all database partitions of the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME FROM TABLE(SNAP_GET_DB_V95(’’, -2)) AS T
1 record(s) selected.
Example 2: Retrieve the status, platform, location, and connect time as an aggregate
view across all database partitions for all active databases in the same instance that
contains the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME
FROM TABLE(SNAP_GET_DB_V95(CAST (NULL AS VARCHAR(128)), -2)) AS T
Example 3: This routine can be used by calling the following on the command line:
1 record(s) selected.
Example 4: After running a workload, a user can use the following query with the
table function.
SELECT STATS_CACHE_SIZE, STATS_FABRICATIONS, SYNC_RUNSTATS,
ASYNC_RUNSTATS, STATS_FABRICATE_TIME, SYNC_RUNSTATS_TIME
FROM TABLE (SNAP_GET_DB_V95(’mytestdb’, -1)) AS SNAPDB
Continued
...STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
...-------------------- ------------------
... 2 32
1 record(s) selected.
This administrative view allows you to retrieve database level memory usage
information for the currently connected database.
Refer to Table 123 on page 365 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDB_MEMORY_POOL
administrative view and EXECUTE privilege on the
SNAP_GET_DB_MEMORY_POOL table function.
Example
Retrieve a list of memory pools and their current size for the currently connected
database, SAMPLE.
SELECT POOL_ID, POOL_CUR_SIZE FROM SYSIBMADM.SNAPDB_MEMORY_POOL
12 record(s) selected.
Refer to Table 123 on page 365 for a complete list of information that can be
returned.
Chapter 3. Supported routines and views 363
Syntax
SNAP_GET_DB_MEMORY_POOL ( dbname )
, dbpartitionnum
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_DB_MEMORY_POOL table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DB_MEMORY_POOL table function.
Example
Retrieve a list of memory pools and their current size for all databases.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, POOL_ID, POOL_CUR_SIZE
FROM TABLE(SNAPSHOT_GET_DB_MEMORY_POOL
(CAST(NULL AS VARCHAR(128)), -1)) AS T
24 record(s) selected.
Information returned
Table 123. Information returned by the SNAPDB_MEMORY_POOL administrative view and
the SNAP_GET_DB_MEMORY_POOL table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
POOL_ID VARCHAR(14) pool_id - Memory pool identifier.
This interface returns a text
identifier based on defines in
sqlmon.h, and is one of:
v APP_GROUP
v APPL_CONTROL
v APPLICATION
v BP
v CAT_CACHE
v DATABASE
v DFM
v FCMBP
v IMPORT_POOL
v LOCK_MGR
v MONITOR
v OTHER
v PACKAGE_CACHE
v QUERY
v SHARED_SORT
v SORT
v STATEMENT
v STATISTICS
v UTILITY
POOL_SECONDARY_ID VARCHAR(32) pool_secondary_id - Memory pool
secondary identifier
POOL_CUR_SIZE BIGINT pool_cur_size - Current size of
memory pool
Refer to Table 124 on page 368 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDBM administrative view and
EXECUTE privilege on the SNAP_GET_DBM_V95 table function.
Example
Retrieve database manager status and connection information for all database
partitions.
SELECT DB2_STATUS, DB2START_TIME, LAST_RESET, LOCAL_CONS, REM_CONS_IN,
(AGENTS_CREATED_EMPTY_POOL/AGENTS_FROM_POOL) AS AGENT_USAGE,
DBPARTITIONNUM FROM SYSIBMADM.SNAPDBM ORDER BY DBPARTITIONNUM
Refer to Table 124 on page 368 for a complete list of information that can be
returned.
Syntax
SNAP_GET_DBM_V95 ( )
dbpartitionnum
If dbpartitionnum is 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_DBM_V95 table function calls the snapshot from memory.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DBM_V95 table function.
Example
Retrieve the start time and current status of database partition number 2.
SELECT DB2START_TIME, DB2_STATUS FROM TABLE(SNAP_GET_DBM_V95(2)) AS T
Information returned
Table 124. Information returned by the SNAPDBM administrative view and the SNAP_GET_DBM_V95 table function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
SORT_HEAP_ALLOCATED BIGINT sort_heap_allocated - Total sort heap
allocated
POST_THRESHOLD_SORTS BIGINT post_threshold_sorts - Post threshold sorts
PIPED_SORTS_REQUESTED BIGINT piped_sorts_requested - Piped sorts
requested
PIPED_SORTS_ACCEPTED BIGINT piped_sorts_accepted - Piped sorts accepted
REM_CONS_IN BIGINT rem_cons_in - Remote connections to
database manager
REM_CONS_IN_EXEC BIGINT rem_cons_in_exec - Remote Connections
Executing in the Database Manager monitor
element
LOCAL_CONS BIGINT local_cons - Local connections
LOCAL_CONS_IN_EXEC BIGINT local_cons_in_exec - Local Connections
Executing in the Database Manager monitor
element
CON_LOCAL_DBASES BIGINT con_local_dbases - Local databases with
current connects
AGENTS_REGISTERED BIGINT agents_registered - Agents registered
AGENTS_WAITING_ON_TOKEN BIGINT agents_waiting_on_token - Agents waiting
for a token
DB2_STATUS VARCHAR(12) db2_status - Status of DB2 instance
Refer to Table 125 on page 372 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDBM_MEMORY_POOL
administrative view and EXECUTE privilege on the
SNAP_GET_DBM_MEMORY_POOL table function.
Example
Retrieve a list of the memory pools and their current size for the database manager
of the connected database.
SELECT POOL_ID, POOL_CUR_SIZE FROM SNAPDBM_MEMORY_POOL
Refer to Table 125 on page 372 for a complete list of information that can be
returned.
If dbpartitionnum is 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_DBM_MEMORY_POOL table function takes a snapshot for the
currently connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DBM_MEMORY_POOL table function.
Example
Retrieve a list of the memory pools and their current size for all database partitions
of the database manager of the connected database.
SELECT POOL_ID, POOL_CUR_SIZE, DBPARTITIONNUM
FROM TABLE(SYSPROC.SNAP_GET_DBM_MEMORY_POOL())
AS T ORDER BY DBPARTITIONNUM
This administrative view allows you to retrieve snapshot information from the
detail_log logical data group for the currently connected database.
Refer to Table 126 on page 375 for a complete list of information that is returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDETAILLOG administrative view
and EXECUTE privilege on the SNAP_GET_DETAILLOG_V91 table function.
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
Refer to Table 126 on page 375 for a complete list of information that is returned.
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
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DETAILLOG_V91 table function.
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
This administrative view allows you to retrieve dynsql logical group snapshot
information for the currently connected database.
This view returns information equivalent to the GET SNAPSHOT FOR DYNAMIC
SQL ON database-alias CLP command.
Refer to Table 127 on page 378 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDYN_SQL administrative view
and EXECUTE privilege on the SNAP_GET_DYN_SQL_V95 table function.
Retrieve a list of dynamic SQL run on all database partitions of the currently
connected database, ordered by the number of rows read.
SELECT PREP_TIME_WORST, NUM_COMPILATIONS, SUBSTR(STMT_TEXT, 1, 60)
AS STMT_TEXT, DBPARTITIONNUM
FROM SYSIBMADM.SNAPDYN_SQL ORDER BY ROWS_READ
This table function returns information equivalent to the GET SNAPSHOT FOR
DYNAMIC SQL ON database-alias CLP command.
Refer to Table 127 on page 378 for a complete list of information that can be
returned.
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_DYN_SQL_V95 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DYN_SQL_V95 table function.
Example
Retrieve a list of dynamic SQL run on the currently connected database partition of
the currently connected database, ordered by the number of rows read.
SELECT PREP_TIME_WORST, NUM_COMPILATIONS, SUBSTR(STMT_TEXT, 1, 60)
AS STMT_TEXT FROM TABLE(SNAP_GET_DYN_SQL_V95(’’,-1)) as T
ORDER BY ROWS_READ
After running a workload, user can use the following query with the table
function.
SELECT STATS_FABRICATE_TIME,SYNC_RUNSTATS_TIME
FROM TABLE (SNAP_GET_DYN_SQL_V95(’mytestdb’, -1))
AS SNAPDB
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
2 12
1 30
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
5 10
3 20
2 record(s) selected.
Information returned
Table 127. Information returned by the SNAPDYN_SQL administrative view and the SNAP_GET_DYN_SQL_V95 table
function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
NUM_EXECUTIONS BIGINT num_executions - Statement executions
NUM_COMPILATIONS BIGINT num_compilations - Statement compilations
PREP_TIME_WORST BIGINT prep_time_worst - Statement worst
preparation time
PREP_TIME_BEST BIGINT prep_time_best - Statement best preparation
time
INT_ROWS_DELETED BIGINT int_rows_deleted - Internal rows deleted
Refer to Table 128 on page 382 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPFCM administrative view and
EXECUTE privilege on the SNAP_GET_FCM table function.
Example
Refer to Table 128 on page 382 for a complete list of information that can be
returned.
Syntax
SNAP_GET_FCM ( )
dbpartitionnum
If dbpartitionnum is 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_FCM table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_FCM table function.
Example
Refer to Table 129 on page 384 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPFCM_PART administrative view
and EXECUTE privilege on the SNAP_GET_FCM_PART table function.
Example
Retrieve buffers sent and received information for the fast communication
manager.
SELECT CONNECTION_STATUS, TOTAL_BUFFERS_SENT, TOTAL_BUFFERS_RECEIVED
FROM SYSIBMADM.SNAPFCM_PART WHERE DBPARTITIONNUM = 0
1 record(s) selected.
Refer to Table 129 on page 384 for a complete list of information that can be
returned.
Syntax
SNAP_GET_FCM_PART ( )
dbpartitionnum
If dbpartitionnum is 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_FCM_PART table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_FCM_PART table function.
Example
Retrieve buffers sent and received information for the fast communication manager
for all database partitions.
SELECT FCM_DBPARTITIONNUM, TOTAL_BUFFERS_SENT, TOTAL_BUFFERS_RCVD,
DBPARTITIONNUM FROM TABLE(SNAP_GET_FCM_PART()) AS T
ORDER BY DBPARTITIONNUM
Information returned
Table 129. Information returned by the SNAPFCM_PART administrative view and the
SNAP_GET_FCM_PART table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
CONNECTION_STATUS VARCHAR(10) connection_status - Connection
status. This interface returns a text
identifier based on the defines in
sqlmon.h and is one of:
v INACTIVE
v ACTIVE
v CONGESTED
TOTAL_BUFFERS_SENT BIGINT total_buffers_sent - Total FCM
buffers sent
TOTAL_BUFFERS_RCVD BIGINT total_buffers_rcvd - Total FCM
buffers received
DBPARTITIONNUM SMALLINT The database partition from which
the data was retrieved for this row.
FCM_DBPARTITIONNUM SMALLINT The database partition number to
which data was sent or from which
data was received (as per the
TOTAL_BUFFERS_SENT and
TOTAL_BUFFERS_RCVD columns).
This administrative view allows you to retrieve hadr logical data group snapshot
information for the currently connected database. The data is only returned by this
view if the database is a primary or standby high availability disaster recovery
(HADR) database.
Refer to Table 130 on page 386 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPHADR administrative view and
EXECUTE privilege on the SNAP_GET_HADR table function.
Example
Retrieve the configuration and status information for HADR on the primary
HADR database.
SELECT SUBSTR(DB_NAME, 1, 8) AS DBNAME, HADR_ROLE, HADR_STATE,
HADR_SYNCMODE, HADR_CONNECT_STATUS
FROM SYSIBMADM.SNAPHADR
1 record(s) selected.
Refer to Table 130 on page 386 for a complete list of information that can be
returned.
Syntax
SNAP_GET_HADR ( dbname )
, dbpartitionnum
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_HADR table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_HADR table function.
Example
Retrieve the configuration and status information for HADR for all databases.
SELECT SUBSTR(DB_NAME, 1, 8) AS DBNAME, HADR_ROLE, HADR_STATE,
HADR_SYNCMODE, HADR_CONNECT_STATUS
FROM TABLE (SNAP_GET_HADR (CAST (NULL as VARCHAR(128)), 0)) as T
2 record(s) selected.
Information returned
Table 130. Information returned by the SNAPHADR administrative view and the
SNAP_GET_HADR table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
This administrative view allows you to retrieve lock logical data group snapshot
information for the currently connected database.
Refer to Table 131 on page 390 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPLOCK administrative view and
EXECUTE privilege on the SNAP_GET_LOCK table function.
Example
Retrieve lock information for the database partition 0 of the currently connected
database.
SELECT AGENT_ID, LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_STATUS
FROM SYSIBMADM.SNAPLOCK WHERE DBPARTITIONNUM = 0
388 Administrative Routines and Views
The following is an example of output from this query.
AGENT_ID LOCK_OBJECT_TYPE LOCK_MODE LOCK_STATUS
-------------------- ---------------- --------- -----------
7 TABLE IX GRNT
1 record(s) selected.
Refer to Table 131 on page 390 for a complete list of information that can be
returned.
Syntax
SNAP_GET_LOCK ( dbname )
, dbpartitionnum
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_LOCK table function takes a snapshot for the currently connected
database and database partition number.
Example
Retrieve lock information for the current database partition of the currently
connected database.
SELECT AGENT_ID, LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_STATUS
FROM TABLE(SNAP_GET_LOCK(’’,-1)) as T
2 record(s) selected.
Information returned
Table 131. Information returned by the SNAPLOCK administrative view and the
SNAP_GET_LOCK table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
TAB_FILE_ID BIGINT table_file_id - Table file
identification
This administrative view allows you to retrieve lockwait logical data group
snapshot information for the currently connected database.
Refer to Table 132 on page 395 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPLOCKWAIT administrative view
and EXECUTE privilege on the SNAP_GET_LOCKWAIT table function.
Example
Retrieve lock wait information on database partition 0 for the currently connected
database.
SELECT AGENT_ID, LOCK_MODE, LOCK_OBJECT_TYPE, AGENT_ID_HOLDING_LK,
LOCK_MODE_REQUESTED FROM SYSIBMADM.SNAPLOCKWAIT
WHERE DBPARTITIONNUM = 0
1 record(s) selected.
Refer to Table 132 on page 395 for a complete list of information that can be
returned.
Syntax
SNAP_GET_LOCKWAIT ( dbname )
, dbpartitionnum
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_LOCKWAIT table function takes a snapshot for the currently
connected database and database partition number.
Example
Retrieve lock wait information on current database partition for the currently
connected database.
SELECT AGENT_ID, LOCK_MODE, LOCK_OBJECT_TYPE, AGENT_ID_HOLDING_LK,
LOCK_MODE_REQUESTED FROM TABLE(SNAP_GET_LOCKWAIT(’’,-1)) AS T
1 record(s) selected.
Usage note
To see lock wait information, you must first turn on the default LOCK monitor
switch in the database manager configuration. To have the change take effect
immediately explicitly attach to the instance using CLP and then issue the CLP
command:
UPDATE DATABASE MANAGER CONFIGURATION CLP USING DFT_MON_LOCK ON
The default setting can also be turned on through the ADMIN_CMD stored
procedure. For example:
CALL SYSPROC.ADMIN_CMD(’update dbm cfg using DFT_MON_LOCK ON’)
Information returned
Table 132. Information returned by the SNAPLOCKWAIT administrative view and the
SNAP_GET_LOCKWAIT table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
SUBSECTION_NUMBER BIGINT ss_number - Subsection number
This administrative view allows you to retrieve statement snapshot information for
the currently connected database.
Refer to Table 133 on page 400 for a complete list of information that can be
returned.
398 Administrative Routines and Views
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSTMT administrative view and
EXECUTE privilege on the SNAP_GET_STMT table function.
Example
Retrieve rows read, written and operation performed for statements executed on
the currently connected single-partition database.
SELECT SUBSTR(STMT_TEXT,1,30) AS STMT_TEXT, ROWS_READ, ROWS_WRITTEN,
STMT_OPERATION FROM SYSIBMADM.SNAPSTMT
2 record(s) selected.
Refer to Table 133 on page 400 for a complete list of information that can be
returned.
Syntax
SNAP_GET_STMT ( dbname )
, dbpartitionnum
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_STMT table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_STMT table function.
Example
Retrieve rows read, written and operation performed for statements executed on
current database partition of currently connected database.
SELECT SUBSTR(STMT_TEXT,1,30) AS STMT_TEXT, ROWS_READ,
ROWS_WRITTEN, STMT_OPERATION FROM TABLE(SNAP_GET_STMT(’’,-1)) AS T
Information returned
Table 133. Information returned by the SNAPSTMT administrative view and the
SNAP_GET_STMT table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
This administrative view allows you to retrieve automatic storage path information
for the currently connected database.
Refer to Table 134 on page 405 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSTORAGE_PATHS administrative
view and EXECUTE privilege on the SNAP_GET_STORAGE_PATHS table
function.
Example
Retrieve the storage path for the currently connected single-partition database.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, SUBSTR(DB_STORAGE_PATH,1,8)
AS DB_STORAGE_PATH, SUBSTR(HOSTNAME,1,10) AS HOSTNAME
FROM SYSIBMADM.SNAPSTORAGE_PATHS
1 record(s) selected.
Refer to Table 134 on page 405 for a complete list of information that can be
returned.
Syntax
SNAP_GET_STORAGE_PATHS ( dbname )
, dbpartitionnum
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_STORAGE_PATHS table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_STORAGE_PATHS table function.
Examples
2 record(s) selected
Information returned
The BUFFERPOOL monitor switch must be turned on in order for the file system
information to be returned.
Table 134. Information returned by the SNAPSTORAGE_PATHS administrative view and the
SNAP_GET_STORAGE_PATHS table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
DB_STORAGE_PATH VARCHAR(256) db_storage_path - Automatic
storage path
This administrative view allows you to retrieve subsection logical monitor group
snapshot information for the currently connected database.
Refer to Table 135 on page 408 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSUBSECTION administrative view
and EXECUTE privilege on the SNAP_GET_SUBSECTION table function.
Example
Refer to Table 135 on page 408 for a complete list of information that can be
returned.
Syntax
SNAP_GET_SUBSECTION ( dbname )
, dbpartitionnum
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_SUBSECTION table function takes a snapshot for the currently
connected database and database partition number.
Example
Information returned
Table 135. Information returned by the SNAPSUBSECTION administrative view and the
SNAP_GET_SUBSECTION table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
STMT_TEXT CLOB(16 M) stmt_text - SQL statement text
SS_EXEC_TIME BIGINT ss_exec_time - Subsection execution
elapsed time
TQ_TOT_SEND_SPILLS BIGINT tq_tot_send_spills - Total number of
table queue buffers overflowed
TQ_CUR_SEND_SPILLS BIGINT tq_cur_send_spills - Current
number of table queue buffers
overflowed
TQ_MAX_SEND_SPILLS BIGINT tq_max_send_spills - Maximum
number of table queue buffers
overflows
TQ_ROWS_READ BIGINT tq_rows_read - Number of rows
read from table queues
TQ_ROWS_WRITTEN BIGINT tq_rows_written - Number of rows
written to table queues
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
SS_USR_CPU_TIME_S BIGINT ss_usr_cpu_time - User CPU time
used by subsection
SS_USR_CPU_TIME_MS BIGINT ss_usr_cpu_time - User CPU time
used by subsection
SS_SYS_CPU_TIME_S BIGINT ss_sys_cpu_time - System CPU
time used by subsection
SS_SYS_CPU_TIME_MS BIGINT ss_sys_cpu_time - System CPU
time used by subsection
This view provides the data equivalent to the GET DBM MONITOR SWITCHES
CLP command.
Refer to Table 136 on page 411 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSWITCHES administrative view
and EXECUTE privilege on the SNAP_GET_SWITCHES table function.
Example
Retrieve DBM monitor switches state information for all database partitions.
SELECT UOW_SW_STATE, STATEMENT_SW_STATE, TABLE_SW_STATE, BUFFPOOL_SW_STATE,
LOCK_SW_STATE, SORT_SW_STATE, TIMESTAMP_SW_STATE,
DBPARTITIONNUM FROM SYSIBMADM.SNAPSWITCHES
Chapter 3. Supported routines and views 409
The following is an example of output from this query.
UOW_SW_STATE STATEMENT_SW_STATE TABLE_SW_STATE BUFFPOOL_SW_STATE ...
------------ ------------------ -------------- ----------------- ...
0 0 0 0 ...
0 0 0 0 ...
0 0 0 0 ...
...
3 record selected.
This table function provides the data equivalent to the GET DBM MONITOR
SWITCHES CLP command.
Refer to Table 136 on page 411 for a complete list of information that can be
returned.
Syntax
SNAP_GET_SWITCHES ( )
dbpartitionnum
If dbpartitionnum is 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_SWITCHES table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_SWITCHES table function.
Retrieve DBM monitor switches state information for the current database
partition.
SELECT UOW_SW_STATE, STATEMENT_SW_STATE, TABLE_SW_STATE,
BUFFPOOL_SW_STATE,LOCK_SW_STATE, SORT_SW_STATE, TIMESTAMP_SW_STATE
FROM TABLE(SNAP_GET_SWITCHES(-1)) AS T
Information returned
Table 136. Information returned by the SNAPSWITCHES administrative view and the
SNAP_GET_SWITCHES table function
Column name Data type Description
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
UOW_SW_STATE SMALLINT State of the unit of work monitor
recording switch (0 or 1).
UOW_SW_TIME TIMESTAMP If the unit of work monitor
recording switch is on, the date and
time that this switch was turned
on.
STATEMENT_SW_STATE SMALLINT State of the SQL statement monitor
recording switch (0 or 1).
STATEMENT_SW_TIME TIMESTAMP If the SQL statement monitor
recording switch is on, the date and
time that this switch was turned
on.
TABLE_SW_STATE SMALLINT State of the table activity monitor
recording switch (0 or 1).
TABLE_SW_TIME TIMESTAMP If the table activity monitor
recording switch is on, the date and
time that this switch was turned
on.
BUFFPOOL_SW_STATE SMALLINT State of the buffer pool activity
monitor recording switch (0 or 1).
BUFFPOOL_SW_TIME TIMESTAMP If the buffer pool activity monitor
recording switch is on, the date and
time that this switch was turned
on.
LOCK_SW_STATE SMALLINT State of the lock monitor recording
switch (0 or 1).
This administrative view allows you to retrieve table logical data group snapshot
information for the currently connected database.
Refer to Table 137 on page 414 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTAB administrative view and
EXECUTE privilege on the SNAP_GET_TAB_V91 table function.
Example
1 record selected.
Refer to Table 137 on page 414 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TAB_V91 ( dbname )
, dbpartitionnum
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_TAB_V91 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TAB_V91 table function.
Retrieve a list of active tables as an aggregate view for the currently connected
database.
SELECT SUBSTR(TABSCHEMA,1,8) AS TABSCHEMA, SUBSTR(TABNAME,1,15) AS TABNAME,
TAB_TYPE, DBPARTITIONNUM FROM TABLE(SNAP_GET_TAB(’’,-2)) AS T
Information returned
Table 137. Information returned by the SNAPTAB administrative view and the
SNAP_GET_TAB_V91 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TABSCHEMA VARCHAR(128) table_schema - Table schema name
TABNAME VARCHAR(128) table_name - Table name
TAB_FILE_ID BIGINT table_file_id - Table file
identification
TAB_TYPE VARCHAR(14) table_type - Table type. This
interface returns a text identifier
based on defines in sqlmon.h, and
is one of:
v USER_TABLE
v DROPPED_TABLE
v TEMP_TABLE
v CATALOG_TABLE
v REORG_TABLE
DATA_OBJECT_PAGES BIGINT data_object_pages - Data object
pages
INDEX_OBJECT_PAGES BIGINT index_object_pages - Index object
pages
LOB_OBJECT_PAGES BIGINT lob_object_pages - LOB object
pages
LONG_OBJECT_PAGES BIGINT long_object_pages - Long object
pages
XDA_OBJECT_PAGES BIGINT xda_object_pages - XDA Object
Pages
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
OVERFLOW_ACCESSES BIGINT overflow_accesses - Accesses to
overflowed records
PAGE_REORGS BIGINT page_reorgs - Page reorganizations
DBPARTITIONNUM SMALLINT The database partition from which
the data was retrieved for this row.
Refer to Table 138 on page 417 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTAB_REORG administrative view
and EXECUTE privilege on the SNAP_GET_TAB_REORG table function.
Example
Refer to Table 138 on page 417 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TAB_REORG ( dbname )
, dbpartitionnum
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_TAB_REORG table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TAB_REORG table function.
Information returned
Table 138. Information returned by the SNAPTAB_REORG administrative view and the
SNAP_GET_TAB_REORG table function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
TABNAME VARCHAR table_name - Table name
(128)
TABSCHEMA VARCHAR table_schema - Table schema name
(128)
PAGE_REORGS BIGINT page_reorgs - Page reorganizations
REORG_PHASE VARCHAR reorg_phase - Table reorganize phase. This
(16) interface returns a text identifier based on
defines in sqlmon.h and is one of:
v BUILD
v DICT_SAMPLE
v INDEX_RECREATE
v REPLACE
v SORT
or SORT+DICT_SAMPLE.
REORG_MAX_PHASE INTEGER reorg_max_phase - Maximum table
reorganize phase
BIGINT reorg_current_counter - Table reorganize
REORG_CURRENT_ progress
COUNTER
REORG_MAX_COUNTER BIGINT reorg_max_counter - Total amount of table
reorganization
Either:
v RECLAIM
v RECLUSTER
and either:
v +OFFLINE
v +ONLINE
If access mode is specified, it is one of:
v +ALLOW_NONE
v +ALLOW_READ
v +ALLOW_WRITE
If offline and RECLUSTER option, one of:
v +INDEXSCAN
v +TABLESCAN
If offline, one of:
v +LONGLOB
v +DATAONLY
If offline, and option is specified, any of:
v +CHOOSE_TEMP
v +KEEPDICTIONARY
v +RESETDICTIONARY
If online, and option is specified:
v +NOTRUNCATE
This administrative view allows you to retrieve table space logical data group
snapshot information for the currently connected database.
Refer to Table 139 on page 421 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP administrative view and
EXECUTE privilege on the SNAP_GET_TBSP_V91 table function.
Example
Retrieve a list of table spaces on the catalog database partition for the currently
connected database.
SELECT SUBSTR(TBSP_NAME,1,30) AS TBSP_NAME, TBSP_ID, TBSP_TYPE,
TBSP_CONTENT_TYPE FROM SYSIBMADM.SNAPTBSP WHERE DBPARTITIONNUM = 1
2 record(s) selected.
Refer to Table 139 on page 421 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_V91 ( dbname )
, dbpartitionnum
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_TBSP_V91 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_V91 table function.
Example
Retrieve a list of table spaces for all database partitions for the currently connected
database.
SELECT SUBSTR(TBSP_NAME,1,10) AS TBSP_NAME, TBSP_ID, TBSP_TYPE,
TBSP_CONTENT_TYPE, DBPARTITIONNUM FROM TABLE(SNAP_GET_TBSP_V91(’’)) AS T
8 record(s) selected.
Information returned
Table 139. Information returned by the SNAPTBSP administrative view and the
SNAP_GET_TBSP_V91 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
Refer to Table 140 on page 426 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP_PART administrative view
and EXECUTE privilege on the SNAP_GET_TBSP_PART_V91 table function.
Example
Retrieve a list of table spaces and their state for all database partitions of the
currently connected database.
SELECT SUBSTR(TBSP_NAME,1,30) AS TBSP_NAME, TBSP_ID,
SUBSTR(TBSP_STATE,1,30) AS TBSP_STATE, DBPARTITIONNUM
FROM SYSIBMADM.SNAPTBSP_PART
5 record(s) selected.
Refer to Table 140 on page 426 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_PART_V91 ( dbname )
, dbpartitionnum
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_TBSP_PART_V91 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_PART_V91 table function.
Example
Retrieve a list of table spaces and their state for the connected database partition of
the connected database.
SELECT SUBSTR(TBSP_NAME,1,30) AS TBSP_NAME, TBSP_ID,
SUBSTR(TBSP_STATE,1,30) AS TBSP_STATE
FROM TABLE(SNAP_GET_TBSP_PART_V91(CAST(NULL AS VARCHAR(128)),-1)) AS T
5 record(s) selected.
Information returned
Table 140. Information returned by the SNAPTBSP_PART administrative view and the
SNAP_GET_TBSP_PART_V91 table function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
This administrative view allows you to retrieve quiescer table space snapshot
information for the currently connected database.
Refer to Table 141 on page 431 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP_QUIESCER administrative
view and EXECUTE privilege on the SNAP_GET_TBSP_QUIESCER table
function.
Example
Retrieve information on quiesced table spaces for all database partitions for the
currently connected database.
Refer to Table 141 on page 431 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_QUIESCER ( dbname )
, dbpartitionnum
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_TBSP_QUIESCER table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_QUIESCER table function.
Example
Retrieve information on quiesced table spaces for database partition 1 for the
currently connected database.
SELECT SUBSTR(TBSP_NAME, 1, 10) AS TBSP_NAME, QUIESCER_TS_ID,
QUIESCER_OBJ_ID, QUIESCER_AUTH_ID, QUIESCER_AGENT_ID,
QUIESCER_STATE, DBPARTITIONNUM
FROM TABLE( SYSPROC.SNAP_GET_TBSP_QUIESCER( ’’, 1)) AS T
Information returned
Table 141. Information returned by the SNAPTBSP_QUIESCER administrative view and the
SNAP_GET_TBSP_QUIESCER table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TBSP_NAME VARCHAR(128) tablespace_name - Table space
name
QUIESCER_TS_ID BIGINT quiescer_ts_id - Quiescer table
space identification
QUIESCER_OBJ_ID BIGINT quiescer_obj_id - Quiescer object
identification
QUIESCER_AUTH_ID VARCHAR(128) quiescer_auth_id - Quiescer user
authorization identification
QUIESCER_AGENT_ID BIGINT quiescer_agent_id - Quiescer agent
identification
This administrative view allows you to retrieve range snapshot information for the
currently connected database.
Refer to Table 142 on page 435 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP_RANGE administrative view
and EXECUTE privilege on the SNAP_GET_TBSP_RANGE table function.
Example
Select information about table space ranges for all database partitions for the
currently connected database.
SELECT TBSP_ID, SUBSTR(TBSP_NAME, 1, 15) AS TBSP_NAME, RANGE_NUMBER,
RANGE_STRIPE_SET_NUMBER, RANGE_OFFSET, RANGE_MAX_PAGE,
RANGE_MAX_EXTENT, RANGE_START_STRIPE, RANGE_END_STRIPE,
RANGE_ADJUSTMENT, RANGE_NUM_CONTAINER, RANGE_CONTAINER_ID,
DBPARTITIONNUM FROM SYSIBMADM.SNAPTBSP_RANGE
ORDER BY DBPARTITIONNUM
Refer to Table 142 on page 435 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_RANGE ( dbname )
, dbpartitionnum
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_TBSP_RANGE table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_RANGE table function.
Examples
Select information on the table space range for the table space with tbsp_id = 2 on
the currently connected database partition.
SELECT TBSP_ID, SUBSTR(TBSP_NAME, 1, 15) AS TBSP_NAME, RANGE_NUMBER,
RANGE_STRIPE_SET_NUMBER, RANGE_OFFSET, RANGE_MAX_PAGE, RANGE_MAX_EXTENT,
RANGE_START_STRIPE, RANGE_END_STRIPE, RANGE_ADJUSTMENT,
RANGE_NUM_CONTAINER, RANGE_CONTAINER_ID
FROM TABLE(SNAP_GET_TBSP_RANGE(’’,-1)) AS T WHERE TBSP_ID = 2
Information returned
Table 142. Information returned by the SNAPTBSP_RANGE administrative view and the
SNAP_GET_TBSP_RANGE table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TBSP_ID BIGINT tablespace_id - Table space
identification
TBSP_NAME VARCHAR(128) tablespace_name - Table space
name
RANGE_NUMBER BIGINT range_number - Range number
RANGE_STRIPE_SET_NUMBER BIGINT range_stripe_set_number - Stripe
set number
RANGE_OFFSET BIGINT range_offset - Range offset
RANGE_MAX_PAGE BIGINT range_max_page_number -
Maximum page in range
RANGE_MAX_EXTENT BIGINT range_max_extent - Maximum
extent in range
RANGE_START_STRIPE BIGINT range_start_stripe - Start stripe
RANGE_END_STRIPE BIGINT range_end_stripe - End stripe
RANGE_ADJUSTMENT BIGINT range_adjustment - Range
adjustment
RANGE_NUM_CONTAINER BIGINT range_num_containers - Number of
containers in range
RANGE_CONTAINER_ID BIGINT range_container_id - Range
container
DBPARTITIONNUM SMALLINT The database partition from which
the data was retrieved for this row.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPUTIL administrative view and
EXECUTE privilege on the SNAP_GET_UTIL table function.
Example
Retrieve a list of utilities and their states on all database partitions for all active
databases in the instance that contains the connected database.
SELECT UTILITY_TYPE, UTILITY_PRIORITY, SUBSTR(UTILITY_DESCRIPTION, 1, 72)
AS UTILITY_DESCRIPTION, SUBSTR(UTILITY_DBNAME, 1, 17) AS
UTILITY_DBNAME, UTILITY_STATE, UTILITY_INVOKER_TYPE, DBPARTITIONNUM
FROM SYSIBMADM.SNAPUTIL ORDER BY DBPARTITIONNUM
3 record(s) selected.
Refer to Table 143 on page 437 for a complete list of information that can be
returned.
Syntax
If dbpartitionnum is 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_UTIL table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_UTIL table function.
Example
Retrieve a list of utility ids with their type and state for the currently connected
database partition on database SAMPLE.
SELECT UTILITY_ID, UTILITY_TYPE, STATE
FROM TABLE(SNAP_GET_UTIL(-1)) AS T WHERE UTILITY_DBNAME=’SAMPLE’
1 record(s) selected.
Information returned
Table 143. Information returned by the SNAPUTIL administrative view and the
SNAP_GET_UTIL table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
UTILITY_ID INTEGER utility_id - Utility ID. Unique to a
database partition.
Refer to Table 144 on page 440 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPUTIL_PROGRESS administrative
view and EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table
function.
Example
1 record(s) selected.
Refer to Table 144 on page 440 for a complete list of information that can be
returned.
If dbpartitionnum is 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_UTIL_PROGRESS table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table function.
Example
1 record(s) selected.
Information returned
Table 144. Information returned by the SNAPUTIL_PROGRESS administrative view and the
SNAP_GET_UTIL_PROGRESS table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
UTILITY_ID INTEGER utility_id - Utility ID. Unique to a
database partition.
PROGRESS_SEQ_NUM INTEGER progress_seq_num - Progress
sequence number. If serial, the
number of the phase. If concurrent,
then could be NULL.
SNAP_WRITE_FILE procedure
The SNAP_WRITE_FILE procedure writes system snapshot data to a file in the tmp
subdirectory of the instance directory.
Syntax
SNAP_WRITE_FILE ( requestType , dbname , dbpartitionnum )
Procedure parameters
requestType
An input argument of type VARCHAR (32) that specifies a valid snapshot
request type. The possible request types are text identifiers based on defines in
sqlmon.h, and are one of:
Authorization
Example
This will result in snapshot data being written to the instance temporary directory,
which is sqllib/tmp/SQLMA_DB2.dat on UNIX operating systems, and
sqllib\DB2\tmp\SQLMA_DB2.dat on a Windows operating system.
Usage notes
This administrative view allows you to retrieve agent logical data group
application snapshot information for the currently connected database.
Refer to Table 115 on page 320 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAGENT administrative view and
EXECUTE privilege on the SNAP_GET_AGENT table function.
Example
Retrieve all application snapshot information for the currently connected database
from the agent logical data group.
SELECT * FROM SYSIBMADM.SNAPAGENT
Syntax
SNAP_GET_AGENT ( dbname )
, dbpartitionnum
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_AGENT table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_AGENT table function.
Example
Retrieve all application snapshot information for all applications in all active
databases.
SELECT * FROM TABLE(SNAP_GET_AGENT(CAST(NULL AS VARCHAR(128)), -1)) AS T
6 record(s) selected.
Information returned
Table 145. Information returned by the SNAPAGENT administrative view and the
SNAP_GET_AGENT table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
AGENT_PID BIGINT agent_pid - Engine dispatchable
unit (EDU)
LOCK_TIMEOUT_VAL BIGINT lock_timeout_val - Lock timeout
(seconds)
DBPARTITIONNUM SMALLINT The database partition from which
the data for the row was retrieved.
This administrative view allows you to retrieve the memory_pool logical data
group snapshot information about memory usage at the agent level for the
currently connected database.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAGENT_MEMORY_POOL
administrative view and EXECUTE privilege on the
SNAP_GET_AGENT_MEMORY_POOL table function.
Example
9 record(s) selected.
Refer to Table 116 on page 323 for a complete list of information that can be
returned.
Syntax
SNAP_GET_AGENT_MEMORY_POOL ( dbname )
, dbpartitionnum
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_AGENT_MEMORY_POOL table function takes a snapshot for the
currently connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_AGENT_MEMORY_POOL table
function.
Example
Retrieve a list of memory pools and their current size for all databases.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, AGENT_ID, POOL_ID, POOL_CUR_SIZE
FROM TABLE(SNAP_GET_AGENT_MEMORY_POOL(CAST (NULL AS VARCHAR(128)), -1))
AS T
18 record(s) selected.
This administrative view allows you to retrieve appl_info logical data group
snapshot information for the currently connected database.
Refer to Table 117 on page 327 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAPPL_INFO administrative view
and EXECUTE privilege on the SNAP_GET_APPL_INFO_V95 table function.
Example
2 record(s) selected.
Syntax
SNAP_GET_APPL_INFO_V95 ( dbname )
, dbpartitionnum
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_APPL_INFO_V95 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_APPL_INFO_V95 table function.
Examples
4 record(s) selected.
3 record(s) selected.
Information returned
Table 147. Information returned by the SNAPAPPL_INFO administrative view and the
SNAP_GET_APPL_INFO_V95 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
This administrative view allows you to retrieve appl logical data group snapshot
information for the currently connected database.
Refer to Table 118 on page 334 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPAPPL administrative view and
EXECUTE privilege on the SNAP_GET_APPL_V95 table function.
Example
Retrieve details on rows read and written for each application in the connected
database.
1 record(s) selected.
Refer to Table 118 on page 334 for a complete list of information that can be
returned.
Syntax
SNAP_GET_APPL_V95 ( dbname )
, dbpartitionnum
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
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_APPL_V95 table function.
Example
Retrieve details on rows read and written for each application for all active
databases.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, AGENT_ID, ROWS_READ, ROWS_WRITTEN
FROM TABLE (SNAP_GET_APPL_V95(CAST(NULL AS VARCHAR(128)),-1)) AS T
Information returned
Table 148. Information returned by the SNAPAPPL administrative view and the
SNAP_GET_APPL_V95 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
UOW_LOG_SPACE_USED BIGINT uow_log_space_used - Unit of
work log space used
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
INACT_STMTHIST_SZ BIGINT stmt_history_list_size - Statement
history list size
POOL_DATA_L_READS BIGINT pool_data_l_reads - Buffer pool
data logical reads
POOL_DATA_P_READS BIGINT pool_data_p_reads - Buffer pool
data physical reads
POOL_DATA_WRITES BIGINT pool_data_writes - Buffer pool data
writes
POOL_INDEX_L_READS BIGINT pool_index_l_reads - Buffer pool
index logical reads
POOL_INDEX_P_READS BIGINT pool_index_p_reads - Buffer pool
index physical reads
This administrative view allows you to retrieve bufferpool logical group snapshot
information for the currently connected database.
Refer to Table 119 on page 342 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPBP administrative view and
EXECUTE privilege on the SNAP_GET_BP_V95 table function.
Example
Retrieve data and index writes for all the bufferpools of the currently connected
database.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME,SUBSTR(BP_NAME,1,15)
AS BP_NAME,POOL_DATA_WRITES,POOL_INDEX_WRITES
FROM SYSIBMADM.SNAPBP
5 record(s) selected
Syntax
SNAP_GET_BP_V95 ( dbname )
, dbpartitionnum
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_BP_V95 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_BP_V95 table function.
Example
Retrieve total physical and logical reads for all bufferpools for all active databases
for the currently connected database partition.
SELECT SUBSTR(T.DB_NAME,1,10) AS DB_NAME,
SUBSTR(T.BP_NAME,1,20) AS BP_NAME,
(T.POOL_DATA_L_READS+T.POOL_INDEX_L_READS) AS TOTAL_LOGICAL_READS,
(T.POOL_DATA_P_READS+T.POOL_INDEX_P_READS) AS TOTAL_PHYSICAL_READS,
T.DBPARTITIONNUM
FROM TABLE(SNAP_GET_BP_V95(CAST(NULL AS VARCHAR(128)), -1)) AS T
3 record(s) selected.
Information returned
Table 149. Information returned by the SNAPBP administrative view and the
SNAP_GET_BP_V95 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
BP_NAME VARCHAR(128) bp_name - Buffer pool name
DB_NAME VARCHAR(128) db_name - Database name
DB_PATH VARCHAR(1024) db_path - Database path
INPUT_DB_ALIAS VARCHAR(128) input_db_alias - Input database
alias
POOL_DATA_L_READS BIGINT pool_data_l_reads - Buffer pool
data logical reads
POOL_DATA_P_READS BIGINT pool_data_p_reads - Buffer pool
data physical reads
POOL_DATA_WRITES BIGINT pool_data_writes - Buffer pool data
writes
POOL_INDEX_L_READS BIGINT pool_index_l_reads - Buffer pool
index logical reads
POOL_INDEX_P_READS BIGINT pool_index_p_reads - Buffer pool
index physical reads
POOL_INDEX_WRITES BIGINT pool_index_writes - Buffer pool
index writes
POOL_XDA_L_READS BIGINT pool_xda_l_reads - Buffer Pool
XDA Data Logical Reads
POOL_XDA_P_READS BIGINT pool_xda_p_reads - Buffer Pool
XDA Data Physical Reads
POOL_XDA_WRITES BIGINT pool_xda_writes - Buffer Pool XDA
Data Writes
POOL_READ_TIME BIGINT pool_read_time - Total buffer pool
physical read time
POOL_WRITE_TIME BIGINT pool_write_time - Total buffer pool
physical write time
POOL_ASYNC_DATA_READS BIGINT pool_async_data_reads - Buffer
pool asynchronous data reads
POOL_ASYNC_DATA_WRITES BIGINT pool_async_data_writes - Buffer
pool asynchronous data writes
Refer to Table 120 on page 347 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPBP_PART administrative view and
EXECUTE privilege on the SNAP_GET_BP_PART table function.
Example
Refer to Table 120 on page 347 for a complete list of information that can be
returned.
Syntax
SNAP_GET_BP_PART ( dbname )
, dbpartitionnum
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_BP_PART table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_BP_PART table function.
Example
Retrieve data for all bufferpools for all active databases when connected to the
SAMPLE database.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, SUBSTR(BP_NAME,1,15) AS BP_NAME,
BP_CUR_BUFFSZ, BP_NEW_BUFFSZ, BP_PAGES_LEFT_TO_REMOVE, BP_TBSP_USE_COUNT
FROM TABLE(SNAP_GET_BP_PART(CAST(NULL AS VARCHAR(128)),-1)) AS T
...
...
Refer to Table 121 on page 350 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPCONTAINER administrative view
and EXECUTE privilege on the SNAP_GET_CONTAINER_V91 table function.
Retrieve details for the table space containers for all database partitions for the
currently connected database.
SELECT SNAPSHOT_TIMESTAMP, SUBSTR(TBSP_NAME, 1, 15) AS TBSP_NAME,
TBSP_ID, SUBSTR(CONTAINER_NAME, 1, 20) AS CONTAINER_NAME,
CONTAINER_ID, CONTAINER_TYPE, ACCESSIBLE, DBPARTITIONNUM
FROM SYSIBMADM.SNAPCONTAINER ORDER BY DBPARTITIONNUM
Refer to Table 121 on page 350 for a complete list of information that can be
returned.
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_CONTAINER_V91 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_CONTAINER_V91 table function.
Example
Retrieve details for the table space containers on the currently connected database
on the currently connected database partition.
SELECT SNAPSHOT_TIMESTAMP, TBSP_NAME, TBSP_ID, CONTAINER_NAME,
CONTAINER_ID, CONTAINER_TYPE, ACCESSIBLE
FROM TABLE(SNAP_GET_CONTAINER_V91(’’,-1)) AS T
Information returned
This administrative view allows you to retrieve snapshot information from the
dbase logical group for the currently connected database.
Refer to Table 122 on page 354 for a complete list of information that is returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDB administrative view and
EXECUTE privilege on the SNAP_GET_DB_V95 table function.
Examples
Retrieve the status, platform, location, and connect time for all database partitions
of the currently connected database.
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
3 record(s) selected.
This routine can be used by calling the following on the command line:
SELECT TOTAL_OLAP_FUNCS, OLAP_FUNC_OVERFLOWS, ACTIVE_OLAP_FUNCS
FROM SYSIBMADM.SNAPDB
1 record(s) selected.
1 record(s) selected.
Refer to Table 122 on page 354 for a complete list of information that is returned.
Syntax
SNAP_GET_DB_V95 ( dbname )
, dbpartitionnum
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_DB_V95 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DB_V95 table function.
Examples
Example 1: Retrieve the status, platform, location, and connect time as an aggregate
view across all database partitions of the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME FROM TABLE(SNAP_GET_DB_V95(’’, -2)) AS T
1 record(s) selected.
Example 2: Retrieve the status, platform, location, and connect time as an aggregate
view across all database partitions for all active databases in the same instance that
contains the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME
FROM TABLE(SNAP_GET_DB_V95(CAST (NULL AS VARCHAR(128)), -2)) AS T
Example 3: This routine can be used by calling the following on the command line:
1 record(s) selected.
Example 4: After running a workload, a user can use the following query with the
table function.
SELECT STATS_CACHE_SIZE, STATS_FABRICATIONS, SYNC_RUNSTATS,
ASYNC_RUNSTATS, STATS_FABRICATE_TIME, SYNC_RUNSTATS_TIME
FROM TABLE (SNAP_GET_DB_V95(’mytestdb’, -1)) AS SNAPDB
Continued
...STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
...-------------------- ------------------
... 2 32
1 record(s) selected.
This administrative view allows you to retrieve database level memory usage
information for the currently connected database.
Refer to Table 123 on page 365 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDB_MEMORY_POOL
administrative view and EXECUTE privilege on the
SNAP_GET_DB_MEMORY_POOL table function.
Example
Retrieve a list of memory pools and their current size for the currently connected
database, SAMPLE.
SELECT POOL_ID, POOL_CUR_SIZE FROM SYSIBMADM.SNAPDB_MEMORY_POOL
12 record(s) selected.
Syntax
SNAP_GET_DB_MEMORY_POOL ( dbname )
, dbpartitionnum
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_DB_MEMORY_POOL table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DB_MEMORY_POOL table function.
Example
Retrieve a list of memory pools and their current size for all databases.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, POOL_ID, POOL_CUR_SIZE
FROM TABLE(SNAPSHOT_GET_DB_MEMORY_POOL
(CAST(NULL AS VARCHAR(128)), -1)) AS T
24 record(s) selected.
Information returned
Table 153. Information returned by the SNAPDB_MEMORY_POOL administrative view and
the SNAP_GET_DB_MEMORY_POOL table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
POOL_ID VARCHAR(14) pool_id - Memory pool identifier.
This interface returns a text
identifier based on defines in
sqlmon.h, and is one of:
v APP_GROUP
v APPL_CONTROL
v APPLICATION
v BP
v CAT_CACHE
v DATABASE
v DFM
v FCMBP
v IMPORT_POOL
v LOCK_MGR
v MONITOR
v OTHER
v PACKAGE_CACHE
v QUERY
v SHARED_SORT
v SORT
v STATEMENT
v STATISTICS
v UTILITY
POOL_SECONDARY_ID VARCHAR(32) pool_secondary_id - Memory pool
secondary identifier
Refer to Table 124 on page 368 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDBM administrative view and
EXECUTE privilege on the SNAP_GET_DBM_V95 table function.
Example
Retrieve database manager status and connection information for all database
partitions.
SELECT DB2_STATUS, DB2START_TIME, LAST_RESET, LOCAL_CONS, REM_CONS_IN,
(AGENTS_CREATED_EMPTY_POOL/AGENTS_FROM_POOL) AS AGENT_USAGE,
DBPARTITIONNUM FROM SYSIBMADM.SNAPDBM ORDER BY DBPARTITIONNUM
Refer to Table 124 on page 368 for a complete list of information that can be
returned.
Syntax
SNAP_GET_DBM_V95 ( )
dbpartitionnum
If dbpartitionnum is 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_DBM_V95 table function calls the snapshot from memory.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DBM_V95 table function.
Example
Retrieve the start time and current status of database partition number 2.
SELECT DB2START_TIME, DB2_STATUS FROM TABLE(SNAP_GET_DBM_V95(2)) AS T
Information returned
Table 154. Information returned by the SNAPDBM administrative view and the SNAP_GET_DBM_V95 table function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
SORT_HEAP_ALLOCATED BIGINT sort_heap_allocated - Total sort heap
allocated
POST_THRESHOLD_SORTS BIGINT post_threshold_sorts - Post threshold sorts
PIPED_SORTS_REQUESTED BIGINT piped_sorts_requested - Piped sorts
requested
PIPED_SORTS_ACCEPTED BIGINT piped_sorts_accepted - Piped sorts accepted
REM_CONS_IN BIGINT rem_cons_in - Remote connections to
database manager
REM_CONS_IN_EXEC BIGINT rem_cons_in_exec - Remote Connections
Executing in the Database Manager monitor
element
LOCAL_CONS BIGINT local_cons - Local connections
LOCAL_CONS_IN_EXEC BIGINT local_cons_in_exec - Local Connections
Executing in the Database Manager monitor
element
CON_LOCAL_DBASES BIGINT con_local_dbases - Local databases with
current connects
AGENTS_REGISTERED BIGINT agents_registered - Agents registered
AGENTS_WAITING_ON_TOKEN BIGINT agents_waiting_on_token - Agents waiting
for a token
DB2_STATUS VARCHAR(12) db2_status - Status of DB2 instance
Refer to Table 125 on page 372 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDBM_MEMORY_POOL
administrative view and EXECUTE privilege on the
SNAP_GET_DBM_MEMORY_POOL table function.
Example
Retrieve a list of the memory pools and their current size for the database manager
of the connected database.
SELECT POOL_ID, POOL_CUR_SIZE FROM SNAPDBM_MEMORY_POOL
Refer to Table 125 on page 372 for a complete list of information that can be
returned.
If dbpartitionnum is 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_DBM_MEMORY_POOL table function takes a snapshot for the
currently connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DBM_MEMORY_POOL table function.
Example
Retrieve a list of the memory pools and their current size for all database partitions
of the database manager of the connected database.
SELECT POOL_ID, POOL_CUR_SIZE, DBPARTITIONNUM
FROM TABLE(SYSPROC.SNAP_GET_DBM_MEMORY_POOL())
AS T ORDER BY DBPARTITIONNUM
This administrative view allows you to retrieve snapshot information from the
detail_log logical data group for the currently connected database.
Refer to Table 126 on page 375 for a complete list of information that is returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDETAILLOG administrative view
and EXECUTE privilege on the SNAP_GET_DETAILLOG_V91 table function.
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
Refer to Table 126 on page 375 for a complete list of information that is returned.
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
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DETAILLOG_V91 table function.
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
This administrative view allows you to retrieve dynsql logical group snapshot
information for the currently connected database.
This view returns information equivalent to the GET SNAPSHOT FOR DYNAMIC
SQL ON database-alias CLP command.
Refer to Table 127 on page 378 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPDYN_SQL administrative view
and EXECUTE privilege on the SNAP_GET_DYN_SQL_V95 table function.
Retrieve a list of dynamic SQL run on all database partitions of the currently
connected database, ordered by the number of rows read.
SELECT PREP_TIME_WORST, NUM_COMPILATIONS, SUBSTR(STMT_TEXT, 1, 60)
AS STMT_TEXT, DBPARTITIONNUM
FROM SYSIBMADM.SNAPDYN_SQL ORDER BY ROWS_READ
This table function returns information equivalent to the GET SNAPSHOT FOR
DYNAMIC SQL ON database-alias CLP command.
Refer to Table 127 on page 378 for a complete list of information that can be
returned.
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_DYN_SQL_V95 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DYN_SQL_V95 table function.
Example
Retrieve a list of dynamic SQL run on the currently connected database partition of
the currently connected database, ordered by the number of rows read.
SELECT PREP_TIME_WORST, NUM_COMPILATIONS, SUBSTR(STMT_TEXT, 1, 60)
AS STMT_TEXT FROM TABLE(SNAP_GET_DYN_SQL_V95(’’,-1)) as T
ORDER BY ROWS_READ
After running a workload, user can use the following query with the table
function.
SELECT STATS_FABRICATE_TIME,SYNC_RUNSTATS_TIME
FROM TABLE (SNAP_GET_DYN_SQL_V95(’mytestdb’, -1))
AS SNAPDB
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
2 12
1 30
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
5 10
3 20
2 record(s) selected.
Information returned
Table 157. Information returned by the SNAPDYN_SQL administrative view and the SNAP_GET_DYN_SQL_V95 table
function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
NUM_EXECUTIONS BIGINT num_executions - Statement executions
NUM_COMPILATIONS BIGINT num_compilations - Statement compilations
PREP_TIME_WORST BIGINT prep_time_worst - Statement worst
preparation time
PREP_TIME_BEST BIGINT prep_time_best - Statement best preparation
time
INT_ROWS_DELETED BIGINT int_rows_deleted - Internal rows deleted
Refer to Table 128 on page 382 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPFCM administrative view and
EXECUTE privilege on the SNAP_GET_FCM table function.
Example
Refer to Table 128 on page 382 for a complete list of information that can be
returned.
Syntax
SNAP_GET_FCM ( )
dbpartitionnum
If dbpartitionnum is 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_FCM table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_FCM table function.
Example
Refer to Table 129 on page 384 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPFCM_PART administrative view
and EXECUTE privilege on the SNAP_GET_FCM_PART table function.
Example
Retrieve buffers sent and received information for the fast communication
manager.
SELECT CONNECTION_STATUS, TOTAL_BUFFERS_SENT, TOTAL_BUFFERS_RECEIVED
FROM SYSIBMADM.SNAPFCM_PART WHERE DBPARTITIONNUM = 0
1 record(s) selected.
Refer to Table 129 on page 384 for a complete list of information that can be
returned.
Syntax
SNAP_GET_FCM_PART ( )
dbpartitionnum
If dbpartitionnum is 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_FCM_PART table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_FCM_PART table function.
Example
Retrieve buffers sent and received information for the fast communication manager
for all database partitions.
SELECT FCM_DBPARTITIONNUM, TOTAL_BUFFERS_SENT, TOTAL_BUFFERS_RCVD,
DBPARTITIONNUM FROM TABLE(SNAP_GET_FCM_PART()) AS T
ORDER BY DBPARTITIONNUM
Information returned
Table 159. Information returned by the SNAPFCM_PART administrative view and the
SNAP_GET_FCM_PART table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
CONNECTION_STATUS VARCHAR(10) connection_status - Connection
status. This interface returns a text
identifier based on the defines in
sqlmon.h and is one of:
v INACTIVE
v ACTIVE
v CONGESTED
TOTAL_BUFFERS_SENT BIGINT total_buffers_sent - Total FCM
buffers sent
TOTAL_BUFFERS_RCVD BIGINT total_buffers_rcvd - Total FCM
buffers received
DBPARTITIONNUM SMALLINT The database partition from which
the data was retrieved for this row.
FCM_DBPARTITIONNUM SMALLINT The database partition number to
which data was sent or from which
data was received (as per the
TOTAL_BUFFERS_SENT and
TOTAL_BUFFERS_RCVD columns).
This administrative view allows you to retrieve hadr logical data group snapshot
information for the currently connected database. The data is only returned by this
view if the database is a primary or standby high availability disaster recovery
(HADR) database.
Refer to Table 130 on page 386 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPHADR administrative view and
EXECUTE privilege on the SNAP_GET_HADR table function.
Example
Retrieve the configuration and status information for HADR on the primary
HADR database.
SELECT SUBSTR(DB_NAME, 1, 8) AS DBNAME, HADR_ROLE, HADR_STATE,
HADR_SYNCMODE, HADR_CONNECT_STATUS
FROM SYSIBMADM.SNAPHADR
1 record(s) selected.
Refer to Table 130 on page 386 for a complete list of information that can be
returned.
Syntax
SNAP_GET_HADR ( dbname )
, dbpartitionnum
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_HADR table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_HADR table function.
Example
Retrieve the configuration and status information for HADR for all databases.
SELECT SUBSTR(DB_NAME, 1, 8) AS DBNAME, HADR_ROLE, HADR_STATE,
HADR_SYNCMODE, HADR_CONNECT_STATUS
FROM TABLE (SNAP_GET_HADR (CAST (NULL as VARCHAR(128)), 0)) as T
2 record(s) selected.
Information returned
Table 160. Information returned by the SNAPHADR administrative view and the
SNAP_GET_HADR table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
This administrative view allows you to retrieve lock logical data group snapshot
information for the currently connected database.
Refer to Table 131 on page 390 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPLOCK administrative view and
EXECUTE privilege on the SNAP_GET_LOCK table function.
Example
Retrieve lock information for the database partition 0 of the currently connected
database.
1 record(s) selected.
Refer to Table 131 on page 390 for a complete list of information that can be
returned.
Syntax
SNAP_GET_LOCK ( dbname )
, dbpartitionnum
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_LOCK table function takes a snapshot for the currently connected
database and database partition number.
Example
Retrieve lock information for the current database partition of the currently
connected database.
SELECT AGENT_ID, LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_STATUS
FROM TABLE(SNAP_GET_LOCK(’’,-1)) as T
2 record(s) selected.
Information returned
Table 161. Information returned by the SNAPLOCK administrative view and the
SNAP_GET_LOCK table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
TAB_FILE_ID BIGINT table_file_id - Table file
identification
This administrative view allows you to retrieve lockwait logical data group
snapshot information for the currently connected database.
Refer to Table 132 on page 395 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPLOCKWAIT administrative view
and EXECUTE privilege on the SNAP_GET_LOCKWAIT table function.
Example
Retrieve lock wait information on database partition 0 for the currently connected
database.
SELECT AGENT_ID, LOCK_MODE, LOCK_OBJECT_TYPE, AGENT_ID_HOLDING_LK,
LOCK_MODE_REQUESTED FROM SYSIBMADM.SNAPLOCKWAIT
WHERE DBPARTITIONNUM = 0
1 record(s) selected.
Refer to Table 132 on page 395 for a complete list of information that can be
returned.
Syntax
SNAP_GET_LOCKWAIT ( dbname )
, dbpartitionnum
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_LOCKWAIT table function takes a snapshot for the currently
connected database and database partition number.
Example
Retrieve lock wait information on current database partition for the currently
connected database.
SELECT AGENT_ID, LOCK_MODE, LOCK_OBJECT_TYPE, AGENT_ID_HOLDING_LK,
LOCK_MODE_REQUESTED FROM TABLE(SNAP_GET_LOCKWAIT(’’,-1)) AS T
1 record(s) selected.
Usage note
To see lock wait information, you must first turn on the default LOCK monitor
switch in the database manager configuration. To have the change take effect
immediately explicitly attach to the instance using CLP and then issue the CLP
command:
UPDATE DATABASE MANAGER CONFIGURATION CLP USING DFT_MON_LOCK ON
The default setting can also be turned on through the ADMIN_CMD stored
procedure. For example:
CALL SYSPROC.ADMIN_CMD(’update dbm cfg using DFT_MON_LOCK ON’)
Information returned
Table 162. Information returned by the SNAPLOCKWAIT administrative view and the
SNAP_GET_LOCKWAIT table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
SUBSECTION_NUMBER BIGINT ss_number - Subsection number
This administrative view allows you to retrieve statement snapshot information for
the currently connected database.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSTMT administrative view and
EXECUTE privilege on the SNAP_GET_STMT table function.
Example
Retrieve rows read, written and operation performed for statements executed on
the currently connected single-partition database.
SELECT SUBSTR(STMT_TEXT,1,30) AS STMT_TEXT, ROWS_READ, ROWS_WRITTEN,
STMT_OPERATION FROM SYSIBMADM.SNAPSTMT
2 record(s) selected.
Refer to Table 133 on page 400 for a complete list of information that can be
returned.
Syntax
SNAP_GET_STMT ( dbname )
, dbpartitionnum
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_STMT table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_STMT table function.
Example
Retrieve rows read, written and operation performed for statements executed on
current database partition of currently connected database.
SELECT SUBSTR(STMT_TEXT,1,30) AS STMT_TEXT, ROWS_READ,
ROWS_WRITTEN, STMT_OPERATION FROM TABLE(SNAP_GET_STMT(’’,-1)) AS T
Information returned
Table 163. Information returned by the SNAPSTMT administrative view and the
SNAP_GET_STMT table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
This administrative view allows you to retrieve automatic storage path information
for the currently connected database.
Refer to Table 134 on page 405 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSTORAGE_PATHS administrative
view and EXECUTE privilege on the SNAP_GET_STORAGE_PATHS table
function.
Example
Retrieve the storage path for the currently connected single-partition database.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, SUBSTR(DB_STORAGE_PATH,1,8)
AS DB_STORAGE_PATH, SUBSTR(HOSTNAME,1,10) AS HOSTNAME
FROM SYSIBMADM.SNAPSTORAGE_PATHS
1 record(s) selected.
Refer to Table 134 on page 405 for a complete list of information that can be
returned.
Syntax
SNAP_GET_STORAGE_PATHS ( dbname )
, dbpartitionnum
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_STORAGE_PATHS table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_STORAGE_PATHS table function.
Examples
2 record(s) selected
Information returned
The BUFFERPOOL monitor switch must be turned on in order for the file system
information to be returned.
Table 164. Information returned by the SNAPSTORAGE_PATHS administrative view and the
SNAP_GET_STORAGE_PATHS table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
DB_STORAGE_PATH VARCHAR(256) db_storage_path - Automatic
storage path
This administrative view allows you to retrieve subsection logical monitor group
snapshot information for the currently connected database.
Refer to Table 135 on page 408 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSUBSECTION administrative view
and EXECUTE privilege on the SNAP_GET_SUBSECTION table function.
Example
Refer to Table 135 on page 408 for a complete list of information that can be
returned.
Syntax
SNAP_GET_SUBSECTION ( dbname )
, dbpartitionnum
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_SUBSECTION table function takes a snapshot for the currently
connected database and database partition number.
Example
Information returned
Table 165. Information returned by the SNAPSUBSECTION administrative view and the
SNAP_GET_SUBSECTION table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
STMT_TEXT CLOB(16 M) stmt_text - SQL statement text
SS_EXEC_TIME BIGINT ss_exec_time - Subsection execution
elapsed time
TQ_TOT_SEND_SPILLS BIGINT tq_tot_send_spills - Total number of
table queue buffers overflowed
TQ_CUR_SEND_SPILLS BIGINT tq_cur_send_spills - Current
number of table queue buffers
overflowed
TQ_MAX_SEND_SPILLS BIGINT tq_max_send_spills - Maximum
number of table queue buffers
overflows
TQ_ROWS_READ BIGINT tq_rows_read - Number of rows
read from table queues
TQ_ROWS_WRITTEN BIGINT tq_rows_written - Number of rows
written to table queues
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
SS_USR_CPU_TIME_S BIGINT ss_usr_cpu_time - User CPU time
used by subsection
SS_USR_CPU_TIME_MS BIGINT ss_usr_cpu_time - User CPU time
used by subsection
SS_SYS_CPU_TIME_S BIGINT ss_sys_cpu_time - System CPU
time used by subsection
SS_SYS_CPU_TIME_MS BIGINT ss_sys_cpu_time - System CPU
time used by subsection
This view provides the data equivalent to the GET DBM MONITOR SWITCHES
CLP command.
Refer to Table 136 on page 411 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPSWITCHES administrative view
and EXECUTE privilege on the SNAP_GET_SWITCHES table function.
Example
Retrieve DBM monitor switches state information for all database partitions.
This table function provides the data equivalent to the GET DBM MONITOR
SWITCHES CLP command.
Refer to Table 136 on page 411 for a complete list of information that can be
returned.
Syntax
SNAP_GET_SWITCHES ( )
dbpartitionnum
If dbpartitionnum is 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_SWITCHES table function takes a snapshot for the currently connected
database and database partition number.
Examples
Retrieve DBM monitor switches state information for the current database
partition.
SELECT UOW_SW_STATE, STATEMENT_SW_STATE, TABLE_SW_STATE,
BUFFPOOL_SW_STATE,LOCK_SW_STATE, SORT_SW_STATE, TIMESTAMP_SW_STATE
FROM TABLE(SNAP_GET_SWITCHES(-1)) AS T
Information returned
Table 166. Information returned by the SNAPSWITCHES administrative view and the
SNAP_GET_SWITCHES table function
Column name Data type Description
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
UOW_SW_STATE SMALLINT State of the unit of work monitor
recording switch (0 or 1).
UOW_SW_TIME TIMESTAMP If the unit of work monitor
recording switch is on, the date and
time that this switch was turned
on.
STATEMENT_SW_STATE SMALLINT State of the SQL statement monitor
recording switch (0 or 1).
STATEMENT_SW_TIME TIMESTAMP If the SQL statement monitor
recording switch is on, the date and
time that this switch was turned
on.
TABLE_SW_STATE SMALLINT State of the table activity monitor
recording switch (0 or 1).
TABLE_SW_TIME TIMESTAMP If the table activity monitor
recording switch is on, the date and
time that this switch was turned
on.
BUFFPOOL_SW_STATE SMALLINT State of the buffer pool activity
monitor recording switch (0 or 1).
This administrative view allows you to retrieve table logical data group snapshot
information for the currently connected database.
Refer to Table 137 on page 414 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTAB administrative view and
EXECUTE privilege on the SNAP_GET_TAB_V91 table function.
1 record selected.
Refer to Table 137 on page 414 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TAB_V91 ( dbname )
, dbpartitionnum
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
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TAB_V91 table function.
Example
Retrieve a list of active tables as an aggregate view for the currently connected
database.
SELECT SUBSTR(TABSCHEMA,1,8) AS TABSCHEMA, SUBSTR(TABNAME,1,15) AS TABNAME,
TAB_TYPE, DBPARTITIONNUM FROM TABLE(SNAP_GET_TAB(’’,-2)) AS T
Information returned
Table 167. Information returned by the SNAPTAB administrative view and the
SNAP_GET_TAB_V91 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TABSCHEMA VARCHAR(128) table_schema - Table schema name
TABNAME VARCHAR(128) table_name - Table name
TAB_FILE_ID BIGINT table_file_id - Table file
identification
TAB_TYPE VARCHAR(14) table_type - Table type. This
interface returns a text identifier
based on defines in sqlmon.h, and
is one of:
v USER_TABLE
v DROPPED_TABLE
v TEMP_TABLE
v CATALOG_TABLE
v REORG_TABLE
DATA_OBJECT_PAGES BIGINT data_object_pages - Data object
pages
INDEX_OBJECT_PAGES BIGINT index_object_pages - Index object
pages
LOB_OBJECT_PAGES BIGINT lob_object_pages - LOB object
pages
LONG_OBJECT_PAGES BIGINT long_object_pages - Long object
pages
XDA_OBJECT_PAGES BIGINT xda_object_pages - XDA Object
Pages
ROWS_READ BIGINT rows_read - Rows read
Refer to Table 138 on page 417 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTAB_REORG administrative view
and EXECUTE privilege on the SNAP_GET_TAB_REORG table function.
Example
Refer to Table 138 on page 417 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TAB_REORG ( dbname )
, dbpartitionnum
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
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TAB_REORG table function.
Example
Information returned
Table 168. Information returned by the SNAPTAB_REORG administrative view and the
SNAP_GET_TAB_REORG table function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
TABNAME VARCHAR table_name - Table name
(128)
TABSCHEMA VARCHAR table_schema - Table schema name
(128)
PAGE_REORGS BIGINT page_reorgs - Page reorganizations
REORG_PHASE VARCHAR reorg_phase - Table reorganize phase. This
(16) interface returns a text identifier based on
defines in sqlmon.h and is one of:
v BUILD
v DICT_SAMPLE
v INDEX_RECREATE
v REPLACE
v SORT
or SORT+DICT_SAMPLE.
Either:
v RECLAIM
v RECLUSTER
and either:
v +OFFLINE
v +ONLINE
If access mode is specified, it is one of:
v +ALLOW_NONE
v +ALLOW_READ
v +ALLOW_WRITE
If offline and RECLUSTER option, one of:
v +INDEXSCAN
v +TABLESCAN
If offline, one of:
v +LONGLOB
v +DATAONLY
If offline, and option is specified, any of:
v +CHOOSE_TEMP
v +KEEPDICTIONARY
v +RESETDICTIONARY
If online, and option is specified:
v +NOTRUNCATE
This administrative view allows you to retrieve table space logical data group
snapshot information for the currently connected database.
Refer to Table 139 on page 421 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP administrative view and
EXECUTE privilege on the SNAP_GET_TBSP_V91 table function.
Example
Retrieve a list of table spaces on the catalog database partition for the currently
connected database.
SELECT SUBSTR(TBSP_NAME,1,30) AS TBSP_NAME, TBSP_ID, TBSP_TYPE,
TBSP_CONTENT_TYPE FROM SYSIBMADM.SNAPTBSP WHERE DBPARTITIONNUM = 1
2 record(s) selected.
Refer to Table 139 on page 421 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_V91 ( dbname )
, dbpartitionnum
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_TBSP_V91 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_V91 table function.
Example
Retrieve a list of table spaces for all database partitions for the currently connected
database.
SELECT SUBSTR(TBSP_NAME,1,10) AS TBSP_NAME, TBSP_ID, TBSP_TYPE,
TBSP_CONTENT_TYPE, DBPARTITIONNUM FROM TABLE(SNAP_GET_TBSP_V91(’’)) AS T
8 record(s) selected.
Information returned
Table 169. Information returned by the SNAPTBSP administrative view and the
SNAP_GET_TBSP_V91 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
Refer to Table 140 on page 426 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP_PART administrative view
and EXECUTE privilege on the SNAP_GET_TBSP_PART_V91 table function.
Example
Retrieve a list of table spaces and their state for all database partitions of the
currently connected database.
SELECT SUBSTR(TBSP_NAME,1,30) AS TBSP_NAME, TBSP_ID,
SUBSTR(TBSP_STATE,1,30) AS TBSP_STATE, DBPARTITIONNUM
FROM SYSIBMADM.SNAPTBSP_PART
5 record(s) selected.
Refer to Table 140 on page 426 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_PART_V91 ( dbname )
, dbpartitionnum
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_TBSP_PART_V91 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_PART_V91 table function.
Example
Retrieve a list of table spaces and their state for the connected database partition of
the connected database.
SELECT SUBSTR(TBSP_NAME,1,30) AS TBSP_NAME, TBSP_ID,
SUBSTR(TBSP_STATE,1,30) AS TBSP_STATE
FROM TABLE(SNAP_GET_TBSP_PART_V91(CAST(NULL AS VARCHAR(128)),-1)) AS T
5 record(s) selected.
Information returned
Table 170. Information returned by the SNAPTBSP_PART administrative view and the
SNAP_GET_TBSP_PART_V91 table function
Description or corresponding monitor
Column name Data type element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
This administrative view allows you to retrieve quiescer table space snapshot
information for the currently connected database.
Refer to Table 141 on page 431 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP_QUIESCER administrative
view and EXECUTE privilege on the SNAP_GET_TBSP_QUIESCER table
function.
Example
Retrieve information on quiesced table spaces for all database partitions for the
currently connected database.
Refer to Table 141 on page 431 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_QUIESCER ( dbname )
, dbpartitionnum
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_TBSP_QUIESCER table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_QUIESCER table function.
Example
Retrieve information on quiesced table spaces for database partition 1 for the
currently connected database.
SELECT SUBSTR(TBSP_NAME, 1, 10) AS TBSP_NAME, QUIESCER_TS_ID,
QUIESCER_OBJ_ID, QUIESCER_AUTH_ID, QUIESCER_AGENT_ID,
QUIESCER_STATE, DBPARTITIONNUM
FROM TABLE( SYSPROC.SNAP_GET_TBSP_QUIESCER( ’’, 1)) AS T
Information returned
Table 171. Information returned by the SNAPTBSP_QUIESCER administrative view and the
SNAP_GET_TBSP_QUIESCER table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TBSP_NAME VARCHAR(128) tablespace_name - Table space
name
QUIESCER_TS_ID BIGINT quiescer_ts_id - Quiescer table
space identification
QUIESCER_OBJ_ID BIGINT quiescer_obj_id - Quiescer object
identification
QUIESCER_AUTH_ID VARCHAR(128) quiescer_auth_id - Quiescer user
authorization identification
QUIESCER_AGENT_ID BIGINT quiescer_agent_id - Quiescer agent
identification
This administrative view allows you to retrieve range snapshot information for the
currently connected database.
Refer to Table 142 on page 435 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPTBSP_RANGE administrative view
and EXECUTE privilege on the SNAP_GET_TBSP_RANGE table function.
Example
Select information about table space ranges for all database partitions for the
currently connected database.
SELECT TBSP_ID, SUBSTR(TBSP_NAME, 1, 15) AS TBSP_NAME, RANGE_NUMBER,
RANGE_STRIPE_SET_NUMBER, RANGE_OFFSET, RANGE_MAX_PAGE,
RANGE_MAX_EXTENT, RANGE_START_STRIPE, RANGE_END_STRIPE,
RANGE_ADJUSTMENT, RANGE_NUM_CONTAINER, RANGE_CONTAINER_ID,
DBPARTITIONNUM FROM SYSIBMADM.SNAPTBSP_RANGE
ORDER BY DBPARTITIONNUM
Refer to Table 142 on page 435 for a complete list of information that can be
returned.
Syntax
SNAP_GET_TBSP_RANGE ( dbname )
, dbpartitionnum
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_TBSP_RANGE table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_TBSP_RANGE table function.
Examples
Select information on the table space range for the table space with tbsp_id = 2 on
the currently connected database partition.
SELECT TBSP_ID, SUBSTR(TBSP_NAME, 1, 15) AS TBSP_NAME, RANGE_NUMBER,
RANGE_STRIPE_SET_NUMBER, RANGE_OFFSET, RANGE_MAX_PAGE, RANGE_MAX_EXTENT,
RANGE_START_STRIPE, RANGE_END_STRIPE, RANGE_ADJUSTMENT,
RANGE_NUM_CONTAINER, RANGE_CONTAINER_ID
FROM TABLE(SNAP_GET_TBSP_RANGE(’’,-1)) AS T WHERE TBSP_ID = 2
Information returned
Table 172. Information returned by the SNAPTBSP_RANGE administrative view and the
SNAP_GET_TBSP_RANGE table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TBSP_ID BIGINT tablespace_id - Table space
identification
TBSP_NAME VARCHAR(128) tablespace_name - Table space
name
RANGE_NUMBER BIGINT range_number - Range number
RANGE_STRIPE_SET_NUMBER BIGINT range_stripe_set_number - Stripe
set number
RANGE_OFFSET BIGINT range_offset - Range offset
RANGE_MAX_PAGE BIGINT range_max_page_number -
Maximum page in range
RANGE_MAX_EXTENT BIGINT range_max_extent - Maximum
extent in range
RANGE_START_STRIPE BIGINT range_start_stripe - Start stripe
RANGE_END_STRIPE BIGINT range_end_stripe - End stripe
RANGE_ADJUSTMENT BIGINT range_adjustment - Range
adjustment
RANGE_NUM_CONTAINER BIGINT range_num_containers - Number of
containers in range
RANGE_CONTAINER_ID BIGINT range_container_id - Range
container
DBPARTITIONNUM SMALLINT The database partition from which
the data was retrieved for this row.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPUTIL administrative view and
EXECUTE privilege on the SNAP_GET_UTIL table function.
Example
Retrieve a list of utilities and their states on all database partitions for all active
databases in the instance that contains the connected database.
SELECT UTILITY_TYPE, UTILITY_PRIORITY, SUBSTR(UTILITY_DESCRIPTION, 1, 72)
AS UTILITY_DESCRIPTION, SUBSTR(UTILITY_DBNAME, 1, 17) AS
UTILITY_DBNAME, UTILITY_STATE, UTILITY_INVOKER_TYPE, DBPARTITIONNUM
FROM SYSIBMADM.SNAPUTIL ORDER BY DBPARTITIONNUM
3 record(s) selected.
Refer to Table 143 on page 437 for a complete list of information that can be
returned.
Syntax
If dbpartitionnum is 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_UTIL table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_UTIL table function.
Example
Retrieve a list of utility ids with their type and state for the currently connected
database partition on database SAMPLE.
SELECT UTILITY_ID, UTILITY_TYPE, STATE
FROM TABLE(SNAP_GET_UTIL(-1)) AS T WHERE UTILITY_DBNAME=’SAMPLE’
1 record(s) selected.
Information returned
Table 173. Information returned by the SNAPUTIL administrative view and the
SNAP_GET_UTIL table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
UTILITY_ID INTEGER utility_id - Utility ID. Unique to a
database partition.
Refer to Table 144 on page 440 for a complete list of information that can be
returned.
Authorization
v SYSMON authority
v SELECT or CONTROL privilege on the SNAPUTIL_PROGRESS administrative
view and EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table
function.
Example
1 record(s) selected.
Refer to Table 144 on page 440 for a complete list of information that can be
returned.
If dbpartitionnum is 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_UTIL_PROGRESS table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table function.
Example
1 record(s) selected.
Information returned
Table 174. Information returned by the SNAPUTIL_PROGRESS administrative view and the
SNAP_GET_UTIL_PROGRESS table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
UTILITY_ID INTEGER utility_id - Utility ID. Unique to a
database partition.
PROGRESS_SEQ_NUM INTEGER progress_seq_num - Progress
sequence number. If serial, the
number of the phase. If concurrent,
then could be NULL.
SNAP_WRITE_FILE procedure
The SNAP_WRITE_FILE procedure writes system snapshot data to a file in the tmp
subdirectory of the instance directory.
Syntax
SNAP_WRITE_FILE ( requestType , dbname , dbpartitionnum )
Procedure parameters
requestType
An input argument of type VARCHAR (32) that specifies a valid snapshot
request type. The possible request types are text identifiers based on defines in
sqlmon.h, and are one of:
Authorization
Example
This will result in snapshot data being written to the instance temporary directory,
which is sqllib/tmp/SQLMA_DB2.dat on UNIX operating systems, and
sqllib\DB2\tmp\SQLMA_DB2.dat on a Windows operating system.
Usage notes
Authorization
v SELECT or CONTROL privilege on the TBSP_UTILIZATION, SNAPTBSP,
SNAPTBSP_PART administrative views and the SYSCAT.TABLESPACES catalog
view.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Example
Information returned
Table 175. Information returned by the TBSP_UTILIZATION administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
TBSP_ID BIGINT tablespace_id - Table space
identification
TBSP_NAME VARCHAR(128) tablespace_name - Table space
name
TBSP_TYPE VARCHAR(10) tablespace_type - Table space type.
This interface returns a text
identifier based on the defines in
sqlutil.h and is one of:
v DMS
v SMS
Authorization
v SELECT or CONTROL privilege on the TOP_DYNAMIC_SQL and
SNAPDYN_SQL administrative views.
v SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority is also required to
access snapshot monitor data.
Example
5 record(s) selected.
Information returned
Table 176. Information returned by the TOP_DYNAMIC_SQL administrative view
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP Timestamp for the report.
NUM_EXECUTIONS BIGINT num_compilations - Statement
compilations
AVERAGE_EXECUTION_TIME_S BIGINT Average execution time.
STMT_SORTS BIGINT stmt_sorts - Statement sorts
SORTS_PER_EXECUTION BIGINT Number of sorts per statement
execution.
STMT_TEXT CLOB(2 M) stmt_text - SQL statement text
DBPARTITIONNUM SMALLINT The database partition from which
the data was retrieved for this row.
GET_ROUTINE_OPTS
GET_ROUTINE_OPTS ( )
Example:
Return the options to be used for the creation of SQL procedures as the result of a
query.
SELECT GET_ROUTINE_OPTS()
FROM SYSIBM.SYSDUMMY1
GET_ROUTINE_SAR
GET_ROUTINE_SAR
The qualified name of the routine is used to determine which routine to retrieve.
The routine that is found must be an SQL routine. Not using a specific name may
result in more than one routine, and an error is raised (SQLSTATE 42725). If this
occurs, the specific name of the desired routine must be used.
The SAR file must include a bind file, which may not be available at the server. If
the bind file cannot be found and stored in the SAR file, an error is raised
(SQLSTATE 55045).
PUT_ROUTINE_SAR
PUT_ROUTINE_SAR ( sarblob )
, new-owner , use-register-flag
The contents of the sarblob argument are extracted into the separate files that make
up the SQL archive file. The shared library and bind files are written to files in a
temporary directory. The environment is set so that the routine definition statement
processing is aware that compiling and linking are not required, and that the
location of the shared library and bind files is available. The contents of the DDL
file are then used to dynamically execute the routine definition statement.
No more than one procedure can be concurrently installed under a given schema.
Processing of this statement might result in the same errors as executing the
routine definition statement using other interfaces. During routine definition
processing, the presence of the shared library and bind files is noted and the
precompile, compile and link steps are skipped. The bind file is used during bind
processing and the contents of both files are copied to the usual directory for an
SQL routine.
REBIND_ROUTINE_PACKAGE
REBIND_ROUTINE_PACKAGE ( type , routine-name-string , resolve )
The qualified name of the routine is used to determine which routine to retrieve.
The routine that is found must be an SQL routine; otherwise, an error is returned
(SQLSTATE 428F7). If a specific name is not used, more than one routine may be
found, and an error is returned (SQLSTATE 42725). If this occurs, the specific name
of the desired routine must be used.
SET_ROUTINE_OPTS
SET_ROUTINE_OPTS ( character-expression )
The SET_ROUTINE_OPTS procedure sets the options that are to be used for the
creation of SQL procedures in the current session. This setting overrides the
instance-wide setting specified in the DB2_SQLROUTINE_PREPOPTS registry
variable.
character-expression
An input argument of type VARCHAR(1024) that specifies the options setting
for the current session.
Specified options are valid for the duration of the session. If the null value is
specified as the argument, the value of the DB2_SQLROUTINE_PREPOPTS registry
variable is restored as the default options setting for the current session. For a list
of the allowed options, see the description of the DB2_SQLROUTINE_PREPOPTS
registry variable under “Query compiler variables”.
Example:
Syntax
ANALYZE_LOG_SPACE ( inDBPGroup , inMainTbSchema , inMainTable ,
pWeight )
Procedure parameters
inDBPGroup
An input argument of type VARCHAR (128) that specifies the database
partition group name.
inMainTbSchema
An input argument of type VARCHAR (128) that specifies the schema of the
main table
inMainTable
An input argument of type VARCHAR (128) that specifies the main table
within the database partition group, usually the largest table in the database
partition group.
analysisType
An input argument of type SMALLINT that specifies an indicator for analysis
type:
v SWRD_USE_STMG_TABLE (1): indicates that the information in the storage
management tables is used to find the table row count per database
partition. This type should only be used if the storage management tables
are setup, and at least one storage snapshot has been taken for the database
partition group that is to be redistributed.
v SWRD_USE_REALTIME_ANALYSIS (2): indicates that a SELECT query is
used to find the table row count per database partition.
inStmgTime
An input argument of type VARCHAR (26) that specifies the timestamp for the
storage management record. This parameter is ignored when analysisType is set
to SWRD_USE_REALTIME_ANALYSIS.
addDropOption
An input argument of type CHAR (1) that specifies database partitions are
being added or dropped:
v ’A’: Adding database partitions.
v ’D’: Dropping database partitions.
Authorization
v SYSADM, SYSMON, SYSCTRL, or SYSMAINT
v EXECUTE privilege on the ANALYZE_LOG_SPACE procedure
Example
Analyze the effect of adding a database partition without applying the changes. In
the following case, the hypothesis is adding database partition 40, 50 and 60 to the
database partition group, and for database partitions 10,20,30,40,50,60, using a
respective target ratio of 1:2:1:2:1:2. Note that in this example, only partitions 10, 20
and 30 actually exist in the database partition group
CALL SYSPROC.ANALYZE_LOG_SPACE(’IBMDEFAULTGROUP’, ’TEST’,
’EMP’, 2, ’ ’, ’A’, ’40,50,60’, ’10,20,30,40,50,60’,
’1,2,1,2,1,2’)
Analyze the effect of dropping a database partition without applying the changes.
In the following case, the hypothesis is dropping database partition 30 from the
database partition group, and redistributing the data in database partitions 10 and
20 using a respective target ratio of 1 : 1. Note that in this example, all database
partitions 10, 20 and 30 should exist in the database partition group
CALL SYSPROC.ANALYZE_LOG_SPACE(’IBMDEFAULTGROUP’, ’TEST’,
’EMP’, 2, ’ ’, ’D’, ’30’, ’10,20’,’1,1’)
Usage notes
“-1” is used as an output value for parameters when their values cannot be
obtained.
The redistribute stored procedures and functions work only in partitioned database
environments, where a distribution key has been defined for each table.
Information returned
The ANALYZE_LOG_SPACE procedure returns a result set (an open cursor) of the
log space analysis results, containing the following fields for each of the database
Syntax
GENERATE_DISTFILE ( inTbSchema , inTbName , fileName )
Procedure parameters
inTbSchema
An input argument of type VARCHAR (128) that specifies the table schema
name.
inTbName
An input argument of type VARCHAR (128) that specifies the table name.
fileName
An input or output argument of type VARCHAR (255) that specifies data
distribution file name. If the given file name is just a file name, the file will be
saved in the tmp sub-directory under the instance directory, and the full file
path name will be returned in the parameter.
Authorization
v EXECUTE privilege on the GENERATE_DISTFILE procedure.
v SELECT privilege on SYSCAT.TABLES, SYSCAT.COLUMNS, and the specified
table.
Example
Usage notes
The redistribute stored procedures and functions work only in partitioned database
environments, where a distribution key has been defined for each table.
Syntax
GET_SWRD_SETTINGS ( dbpgName , matchingSpec , redistMethod ,
Procedure parameters
dbpgName
An input argument of type VARCHAR(128) that specifies the database
partition group name against which the redistribute process is to run.
matchingSpec
An input argument of type SMALLINT that specifies the bitwise field
indentifier(s) from Table 178, indicating the target fields to be returned by the
output parameters. Those output parameters that are not required can be set to
null.
For example, if matchingSpec is set to 96, which is the integer value of
(REDIST_STAGE_SIZE | REDIST_NEXT_STEP), the caller of this function only
needs to provide stageSize and nextStep to receive the values, and the rest of the
output parameters can be null.
Table 178. Bitwise field indentifiers
Field Name Hexadecimal value Decimal value
REDIST_METHOD 0x0001<<0 1
REDIST_PMAP_FILE 0x0001<<1 2
REDIST_DIST_FILE 0x0001<<2 4
REDIST_STEP_SIZE 0x0001<<3 8
REDIST_NUM_STEPS 0x0001<<4 16
redistMethod
An output argument of type SMALLINT that specifies whether the redistribute
is to run using the data distribution file or the target distribution map. There
are two possible return values:
v 2: indicates that the redistribute process will work with a data distribution
file as input.
v 3: indicates that the redistribute process will work with a target distribution
map as input.
pMapFile
An output argument of type VARCHAR (255) that specifies the full path file
name of the target distribution map on the database server.
distFile
An output argument of type VARCHAR (255) that specifies the full path file
name of the data distribution file on the database server.
stepSize
An output argument of type BIGINT that specifies the maximum number of
rows that can be moved before a commit must be called to prevent a log full
situation. The number can be changed in each redistribution step.
totalSteps
An output argument of type SMALLINT that specifies the number of steps it
takes to completely redistribute the given database partition group.
stageSize
An output argument of type SMALLINT that specifies the number of steps to
be run consecutively.
nextStep
An output argument of type SMALLINT that specifies the index separating
which steps have been completed, and what still needs to be run.
processState
An output argument of type SMALLINT that indicates whether or not the
redistribute process will be stopped at the next check point. A check point is
placed at beginning of each redistribute step. If this argument is set to 1, the
step will not start; if the value is 0, the step will proceed.
pNumber
An output argument of type VARCHAR (6000) that might return a list of
comma-separated database partition numbers in a string format. These
partition numbers can be either the database partitions that are currently used
by the database partition group, or the ones to be added or dropped. The
sequence and the count of these partition numbers correspond to the target
partition weight returned by the pWeight variable.
Authorization
Example
Report the content of the step wise redistribution plan for the given database
partition group.
CALL SYSPROC.GET_SWRD_SETTINGS
(’IBMDEFAULTGROUP’, 255, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Usage note
The redistribute stored procedures and functions work only in partitioned database
environments, where a distribution key has been defined for each table.
Syntax
SET_SWRD_SETTINGS ( dbpgName , overwriteSpec , redistMethod ,
Procedure parameters
dbpgName
An input argument of type VARCHAR(128) that specifies the database
partition group name against which the redistribute process is to run.
overwriteSpec
Bitwise field indentifier(s) from Table 179 indicating the target fields to be
written or overwritten into the redistribute settings registry.
Table 179. Bitwise field indentifiers
Field Name Hexadecimal value Decimal value
REDIST_METHOD 0x0001<<0 1
REDIST_PMAP_FILE 0x0001<<1 2
redistMethod
An input argument of type SMALLINT that specifies whether the redistribute
is to run using the data distribution file or the target distribution map. The two
valid input values are:
v 2: indicate that the redistribute process will work with a data distribution
file as input.
v 3: indicate that the redistribute process will work with a target distribution
map as input.
pMapFile
An input argument of type VARCHAR (255) that specifies the full path file
name of the target distribution map on the database server.
distFile
An input argument of type VARCHAR (255) that specifies the full path file
name of the data distribution file on the database server..
stepSize
An input argument of type BIGINT that specifies the maximum number of
rows that can be moved before a commit must be called to prevent a log full
situation. The number can be changed in each redistribution step. The value
“-2” can be used for stepSize to indicate that the number is unlimited.
totalSteps
An input argument of type SMALLINT that specifies the number of steps it
takes to completely redistribute the given database partition group. The value
“-2” can be used totalSteps to indicate that the number is unlimited.
stageSize
An input argument of type SMALLINT that specifies the number of steps to be
run consecutively.
nextStep
An input argument of type SMALLINT that specifies the index separating
which steps have been completed, and what still needs to be run.
processState
An input argument of type SMALLINT that indicates whether or not the
redistribute process will be stopped at the next check point. A check point is
placed at beginning of each redistribute step. If this argument is set to 1, the
step will not start; if the value is 0, the step will proceed.
pNumber
An input argument of type VARCHAR (6000) that can contain a list of
comma-separated database partition numbers in a string format. These
Authorization
Example
Write a step wise redistribution plan into a registry. Setting processState to 1, might
cause a currently running step wise redistribute stored procedure to complete the
current step and stop, until this parameter is reset to 0, and the redistribute stored
procedure is called again.
CALL SYSPROC.SET_SWRD_SETTINGS(’IBMDEFAULTGROUP’, 255, 0, ’ ’,
’$HOME/sqllib/function/TEST.IBMDEFAULTGROUP_swrdData.dst’, 1000,
12, 2, 1, 0, ’10,20,30’, ’50,50,50’)
Usage notes
The redistribute stored procedures and functions work only in partitioned database
environments, where a distribution key has been defined for each table.
Syntax
STEPWISE_REDISTRIBUTE_DBPG ( inDBPGroup , inStartingPoint ,
inNumSteps )
Procedure parameters
inDBPGroup
An input argument of type VARCHAR (128) that specifies the name of the
target database partition group.
inStartingPoint
An input argument of type SMALLINT that specifies the starting point to use.
Authorization
v EXECUTE privilege on the STEPWISE_REDISTRIBUTE_DBPG procedure
v SYSADM, SYSCTRL or DBADM
Example
Usage notes
Since SQL COMMIT statement is called by the redistribute process, running the
redistribute process under a Type-2 connection is not supported.
Syntax
CAPTURE_STORAGEMGMT_INFO ( in_rootType , in_rootSchema ,
in_rootName )
Procedure parameters
in_rootType
An input argument of type SMALLINT. The valid option types are:
v 0 - Database
v 1 - Database Partition Group
v 2 - Table Space
v 4 - Table
v 5 - Index
The input argument cannot be null. If a null value is specified, an SQL0443
error with SQLSTATE 38553, and token DBA7617 is returned.
Authorization
v EXECUTE privilege on the CAPTURE_STORAGEMGMT_INFO procedure.
v EXECUTE privilege on the SYSPROC.DB_PARTITIONS,
SYSPROC.SNAP_GET_CONTAINER, SYSPROC.SNAPSHOT_CNTRFS table
functions.
v SELECT privilege on SYSCAT.TABLES, SYSCAT.TABLESPACES,
SYSCAT.NODEGROUPDEF, SYSCAT.DATABASEPARTITIONS,
SYSCAT.DATAPARTITIONEXPRESSION, SYSCAT.INDEXES, and
SYSCAT.COLUMNS.
Syntax
CREATE_STORAGEMGMT_TABLES ( in_tbspace )
Procedure parameters
in_tbspace
An input argument of type VARCHAR(128) that specifies the table space name.
The input argument cannot be null. If a null value is specified, an SQL0443
error with SQLSTATE 38553, and token DBA7617 is returned.
Authorization
You must also have CREATETAB privilege on the database and USE privilege on
the table space, and either:
v IMPLICIT_SCHEMA authority on the database if the implicit or explicit schema
name DB2TOOLS does not exist.
v CREATEIN privilege on the schema if the schema name of the table exists.
v SYSADM or DBADM authority
Syntax
DROP_STORAGEMGMT_TABLES ( dropSpec )
Procedure parameters
dropSpec
An input argument of type SMALLINT. When dropSpec is set to 0, the process
stops when any error is encountered; when dropSpec is set to 1, the process
continues, ignoring any error it encounters. The input argument cannot be null.
If a null value is specified, an SQL0443 error with SQLSTATE 38553, and token
DBA7617 is returned.
Authorization
The user ID that establishes the database connection must either be the definer of
the storage management tables as recorded in the DEFINER column of
SYSCAT.TABLES, or have at least one of the following privileges:
v SYSADM or DBADM authority
v DROPIN privilege on the schema for these tables
v CONTROL privilege on these tables
Syntax
SYSTS_ADMIN_CMD ( command-string , message-locale , message )
Procedure parameter
command-string
An input argument of type VARCHAR (32K) that specifies a single text search
index administration command that is to be executed. The command syntax is
the same as the DB2 Text Search command with the exception of the
connection options. Connection options are not supported through this
procedure. Commands that are run through this procedure use the current
connection.
message-locale
An input argument of type VARCHAR (33) that specifies the desired language
for any error message text returned. If the argument is null or an empty string,
or the message files for the specified locale are not available on the server,
’en_US’ is used.
message
An output argument of type VARCHAR (32K) that specifies a warning or
informational message for an operation that is considered successful.
Authorization
The procedure currently supports the following DB2 Text Search commands:
v ALTER INDEX
v CLEAR COMMAND LOCKS
v CLEAR EVENTS
v CREATE INDEX
v DISABLE DATABASE
v DROP INDEX
v ENABLE DATABASE
v UPDATE INDEX
Example
Update text search index MYTEXTINDEX in schema DB2TS and return any error
messages in English.
CALL SYSPROC.SYSTS_ADMIN_CMD
(’UPDATE INDEX DB2TS.MYTEXTINDEX FOR TEXT’,’en_US’, ?)";
Return Status = 0
Usage notes
v If the execution of the command is not successful, SQLCODE -20427 and
SQLSTATE 38H14 is returned with the text search specific error message. For
example, if index MYTEXTINDEX already exists and the following statement is
issued:
CALL SYSPROC.SYSTS_ADMIN_CMD (’CREATE INDEX MYTEXTINDEX FOR TEXT
ON DB2TS.TEXTBOOKS (STORY)’, ’en_US’, ?)
the index creation will fail with the following error message.
SQL20427N An error occurred during a text search administration
procedure or command. The error message is "CIE00201 Text search
index "DB2TS "."MYTEXTINDEX" already exists. ". SQLSTATE=38H14
v If an SQLCODE is returned by the procedure, the message might be truncated.
Full message information can be found in the db2diag.log file.
Syntax
SYSTS_ALTER ( index_schema , index_name , update characteristics
, message_locale , message )
update characteristics:
UPDATE FREQUENCY NONE
update frequency
UPDATE MINIMUM minchanges
update frequency:
D ( * ) H ( * ) M ( integer3 )
, ,
integer1 integer2
Procedure parameters
index_schema
An input argument of type VARCHAR(128) that specifies the schema of the
text search index. The index_schema must follow the naming restriction for DB2
schema names. If the argument is null or an empty string, the value of
CURRENT SCHEMA is used. The index_schema is case-sensitive.
index_name
An input argument of type VARCHAR(128) that specifies the name of the
index. Together with index_schema, it uniquely identifies a text search index in
a database. The index_name is case-sensitive.
update characteristics
An input argument of type VARCHAR(32K) that specifies the alter options.
The alter options allowed are as follows:
UPDATE FREQUENCY
Specifies the frequency with which index updates are made. The index will
be updated, if the number of changes is at least the value set for UPDATE
MINIMUM. The update frequency NONE indicates that no further index
updates will be made. This can be useful for a text column in a table with
data that will not change. It is also useful when the user intends to
manually update the index (using the UPDATE INDEX command).
Automatic updates can only be done if the START FOR TEXT command
has been run and the DB2 Text Search instance services are running.
The default frequency value is taken from the view
SYSIBMTS.TSDEFAULTS, where
DEFAULTNAME=’UPDATEFREQUENCY’.
NONE
No automatic updates will be applied to the text index. Any further
index update will have to be started manually.
D The day(s) of the week when the index is updated.
* Every day of the week.
integer1
Specific days of the week, from Sunday to Saturday: 0 to 6
H The hour(s) of the specified day(s) when the index is updated.
* Every hour of the day.
integer2
Specific hours of the day, from midnight to 11 pm: 0 to 23
M The minute(s) of the specified hour(s) when the index is updated.
integer3
Specified as top of the hour (0), or in multiples of 5 minute
increments after the hour: 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 or 55
Authorization
EXECUTE privilege on the SYSTS_ALTER procedure.
The authorization-name for the database connection must have the CONTROL
privilege on the table the text search index was created for.
Examples
Return Status = 0
Usage notes
v Text search administration procedures use an existing connection to the
database. The current transaction might be committed or rolled back depending
on the completion of the procedures. As such, you might want to commit all
A command lock is created at the beginning of a text search index command, and
is destroyed when the command has completed. It prevents undesirable conflict
between different commands.
A cleanup is done automatically of all locks associated with processes that are no
longer alive. This is done to make a text search index accessible to a new search
request. Use of this procedure is required in the rare case that locks remain in
place due to an unexpected system behavior, and need to be cleaned up explicitly.
This procedure issues the CLEAR COMMAND LOCKS text search administration
command on the database server.
Syntax
SYSTS_CLEAR_COMMANDLOCKS ( index_schema , index_name ,
message_locale , message )
Procedure parameters
index_schema
An input argument of type VARCHAR(128) that specifies the schema of the
text index. The index_schema must follow the naming restriction for DB2
Authorization
Examples
Return Status = 0
The name of the event table can be found in the view SYSIBMTS.TSINDEXES in
column EVENTVIEWNAME. Every index update operation produces informational
and, in some cases, error entries in the event table. For automatic updates, the
event table has to be regularly inspected. Document specific errors must be
corrected by changing the document content. After correcting the errors, the events
can be cleared (and should be, in order not to consume too much space).
The procedure issues a CLEAR EVENTS FOR INDEX text search administration
command on the database server.
Syntax
SYSTS_CLEAR_EVENTS ( index_schema , index_name ,
message_locale , message )
Procedure parameters
index_schema
An input argument of type VARCHAR(128) that specifies the schema of the
text search index. The index_schema must follow the naming restriction for DB2
Authorization
Examples
Return Status = 0
Usage notes
v Text search administration procedures use an existing connection to the
database. The current transaction might be committed or rolled back depending
on the completion of the procedures. As such, you might want to commit all
transaction changes to avoid any unexpected impact from such a commit or
rollback. One way to achieve this is to turn on AUTOCOMMIT.
Once the text search index is created, the column can be searched using text search
functions in queries. The index will not contain any data until the text search
UPDATE INDEX command or SYSTS_UPDATE procedure is explicitly executed by
the user, or implicitly executed by the text search instance level services, according
to the defined update frequency for the index.
Syntax
SYSTS_CREATE ( index_schema , index_name , text source ,
text source:
column-name
function-name (column-name)
options:
update characteristics
storage options
update characteristics:
UPDATE FREQUENCY NONE
update frequency
update frequency:
D ( * ) H ( * ) M ( integer3 )
, ,
integer1 integer2
storage options:
COLLECTION DIRECTORY directory
ADMINISTRATION TABLES IN tablespace-name
Procedure parameters
index_schema
An input argument of type VARCHAR(128) that specifies the schema of the
text search index. The index_schema must follow the naming restriction for DB2
schema names. If the argument is null or an empty string, the value of
CURRENT SCHEMA is used. The index_schema is case-sensitive.
index_name
An input argument of type VARCHAR(128) that specifies the name of the
index. Together with index_schema, it uniquely identifies a text search index in
a database. The index_name is case-sensitive.
text source
An input argument of type VARCHAR(1024) that specifies the name of the
column to be indexed. The options are:
table-name
The table name containing the text column. Text search indexes cannot be
created on the following tables:
v range-partitioned tables
v federated tables
v materialized query tables
v views
The table-name is case-sensitive.
text column name
The column name of the column to be indexed.
column-name
The column must be of one of the following data types: CHAR,
VARCHAR, LONG VARCHAR, CLOB, DBCLOB, BLOB, GRAPHIC,
VARGRAPHIC, LONG VARGRAPHIC, or XML. If the data type of the
column is not one of these, use a transformation function specified
with function-schema.function-name to convert the column type to one of
the valid types. Refer to the function-name (column-name) for syntax and
details. Alternatively, you can specify a user-defined external function
that accesses the text documents to be indexed. Only a single text
search index can be created for a column. The column-name is
case-sensitive.
function-name (column-name)
Specifies the schema qualified name, that conforms to DB2 naming
conventions, of an external scalar function that accesses text documents
in a column that is not of a supported type for text searching. Performs
a data type conversion of that value, and returns the value as one of
the supported data types for text searching. Its task is to perform a
Example:
INDEX CONFIGURATION (COMMENT ’Index on User’’s Guide column’)
message_locale
An input argument of type VARCHAR(33) that specifies the locale to be used
for any error message returned. If the argument is null or an empty string, or
the message files for the specified locale are not available on the server,
’en_US’ is used.
message
An output argument of type VARCHAR(32K) that specifies a warning or
informational message for a successfully completed operation.
Examples
Example 1: In the following example, a text search index with index_schema ’db2ts’
and index_name ’myTextIndex’ is created using the SYSTS_CREATE procedure. The
option ’UPDATE MINIMUM 10’ specifies that at least 10 changes should be made to
the text documents associated with the index before an incremental update of the
index should be performed. Any error messages are requested to be returned in
English. When the underlying text search command runs successfully, the output
parameter message is set to indicate the status of the command execution.
CALL SYSPROC.SYSTS_CREATE(’db2ts’, ’myTextIndex’,
’myUserSchema.myBaseTable (myTextColumn)’, ’UPDATE MINIMUM 10’,
’en_US’, ?)
Usage notes
v Text search administration procedures use an existing connection to the
database. The current transaction might be committed or rolled back depending
on the completion of the procedures. As such, you might want to commit all
transaction changes to avoid any unexpected impact from such a commit or
rollback. One way to achieve this is to turn on AUTOCOMMIT.
v Multiple procedures or commands cannot be executed concurrently on a text
search index if they might conflict. Some of the conflicting procedures and
commands are:
– SYSTS_ALTER procedure or ALTER INDEX db2ts command
– SYSTS_CLEAR_EVENTS procedure or CLEAR EVENTS FOR INDEX db2ts
command
– SYSTS_DISABLE procedure or DISABLE DATABASE FOR TEXT db2ts
command
– STOP FOR TEXT db2ts command
– SYSTS_UPDATE procedure or UPDATE INDEX db2ts command
Usage restrictions:
v A primary key must be defined for the table. In DB2 Text Search, a multi-column
DB2 primary key can be used without type limitations. The number of primary
key columns is limited to 2 columns less than the number of primary key
columns allowed by DB2.
v The total length of all primary key columns for a table with DB2 Text Search
indexes is limited to 15 bytes less than the maximum total primary key length
allowed by DB2. Refer to the DB2 restrictions of DB2 CREATE INDEX statement.
Once the Text Search feature has been disabled, text search indexes and commands
are no longer available for use with the database.
The procedure issues a DISABLE DATABASE FOR TEXT text search administration
command on the database server.
Syntax
SYSTS_DISABLE ( options , message_locale , message )
Procedure parameters
options
An input argument of type VARCHAR(128) that specifies the options to be
used when disabling the database. The argument can be set to FORCE. When
this value is specified, all indexes are dropped and the Text Search feature is
disabled by force. No text search indexes are preserved and no error message
Authorization
EXECUTE privilege on the SYSTS_DISABLE procedure.
Examples
Example 1: In the following example, Text Search is disabled for a database using
the SYSTS_DISABLE procedure. The FORCE option is specified to ensure that the
feature is disabled even if text search indexes still exist on tables in the database.
Error messages are specified requested to be returned in English. The message
output parameter is set to an informational message string.
CALL SYSPROC.SYSTS_DISABLE(’FORCE’, ’en_US’, ?)
Return Status = 0
Example 2: In the following example, Text Search is disabled for a database with
existing text search indexes using the SYSTS_DISABLE procedure without
specifying the FORCE option. This results in an error message to the caller. It is
preferable to drop all existing text search indexes prior to disabling the Text Search
feature or alternatively to specify the FORCE option for the options input parameter
value.
CALL SYSPROC.SYSTS_DISABLE(’’, ’en_US’, ?)
Usage notes
v Text search administration procedures use an existing connection to the
database. The current transaction might be committed or rolled back depending
on the completion of the procedures. As such, you might want to commit all
transaction changes to avoid any unexpected impact from such a commit or
rollback. One way to achieve this is to turn on AUTOCOMMIT.
Note: The user is discouraged from usage that results in orphaned collections,
that is, collections that remain defined on the text search server but are not used
by DB2. Here are some cases that cause orphaned collections:
– When a DROP DATABASE CLP command or DROP TABLE statement is
executed without running the SYSTS_DISABLE procedure or a DISABLE
DATABASE FOR TEXT command.
– When the SYSTS_DISABLE procedure is run or a DISABLE DATABASE FOR
TEXT command is executed using the FORCE option.
– Some other error conditions. The CLEANUP FOR TEXT command can be
used in some scenarios.
The procedure issues a DROP INDEX text search administration command on the
database server.
Syntax
SYSTS_DROP ( index_schema , index_name ,
message_locale , message )
Procedure parameters
index_schema
An input argument of type VARCHAR(128) that specifies the schema of the
text search index. The index_schema must follow the naming restriction for DB2
schema names. If the argument is null or an empty string, the value of
CURRENT SCHEMA is used. The index_schema is case-sensitive.
index_name
An input argument of type VARCHAR(128) that specifies the name of the
index. Together with index_schema, it uniquely identifies a text search index in
a database. The index_name is case-sensitive.
message_locale
An input argument of type VARCHAR(33) that specifies the locale to be used
for any error message returned. If the argument is null or an empty string, or
the message files for the specified locale are not available on the server,
’en_US’ is used.
message
An output argument of type VARCHAR(32K) that specifies a warning or
informational message for a successfully completed operation.
Authorization
The authorization-name for the database connection must have one of the
following:
v CONTROL privileges on the table for which the text search index was created.
v DBADM or SYSADM authority. This authorization is used to drop a text index
as part of the DISABLE DATABASE FOR TEXT command with the FORCE
option.
Examples
Example 1: In the following example, the text search index that was created with
index_schema ’db2ts’ and index_name ’myTextIndex’ is being dropped. Any error
messages are requested to be returned in English. When the procedure succeeds,
the output parameter message indicative of the successful operation is returned to
the caller.
CALL SYSPROC.SYSTS_DROP(’db2ts’, ’myTextIndex’, ’en_US’, ?)
Return Status = 0
Usage notes
v Text search administration procedures use an existing connection to the
database. The current transaction might be committed or rolled back depending
on the completion of the procedures. As such, you might want to commit all
transaction changes to avoid any unexpected impact from such a commit or
rollback. One way to achieve this is to turn on AUTOCOMMIT.
v Multiple procedures or commands cannot be executed concurrently on a text
search index if they might conflict. Some of the conflicting procedures and
commands are:
– SYSTS_ALTER procedure or ALTER INDEX db2ts command
– SYSTS_CLEAR_EVENTS procedure or CLEAR EVENTS FOR INDEX db2ts
command
– SYSTS_DISABLE procedure or DISABLE DATABASE FOR TEXT db2ts
command
– STOP FOR TEXT db2ts command
– SYSTS_UPDATE procedure or UPDATE INDEX db2ts command
If there is a conflict, the procedure returns an SQLCODE -20426 and SQLSTATE
38H13.
v Dropping the user table in DB2 does not trigger dropping of indexes, they must
be dropped manually before or after dropping the table.
v When this procedure is run,
– the text search catalog information is updated. The index staging and event
tables are dropped. Triggers on the user table are deleted.
– the index entry in the Text Search Index Data file is deleted. The file contains
a persistent representation of update schedules (also empty ones) for each
index in the instance.
– the collection associated with the text search index definition is removed.
v If, after dropping a text search index, you plan to create a new one on the same
text column, you must first disconnect from and then reconnect to the database
before creating the new text search index.
This procedure issues the ENABLE DATABASE FOR TEXT text search
administration command on the database server.
Syntax
SYSTS_ENABLE ( message_locale , message )
Procedure parameters
message_locale
An input argument of type VARCHAR(33) that specifies the locale to be used
for any error message returned. If the argument is null or an empty string, or
the message files for the specified locale are not available on the server,
’en_US’ is used.
message
An output argument of type VARCHAR(32K) that specifies a warning or
informational message for a successfully completed operation.
Authorization
The authorization-name for the database connection must have SYSADM authority.
Examples
Example 1: Enable the database for text search and return any error messages in
English.
CALL SYSPROC.SYSTS_ENABLE(’en_US’, ?)
Return Status = 0
While the update is being performed, a search is possible. Until completion of the
update, the search operates on a partially updated index.
Syntax
SYSTS_UPDATE ( index_schema , index_name ,
Procedure parameters
index_schema
An input argument of type VARCHAR(128) that specifies the schema of the
text search index. The index_schema must follow the naming restriction for DB2
schema names. If the argument is null or an empty string, the value of
CURRENT SCHEMA is used. The index_schema is case-sensitive.
index_name
An input argument of type VARCHAR(128) that specifies the name of the
index. Together with index_schema, it uniquely identifies a text search index in
a database. The index_name is case-sensitive.
update_options
An input argument of type VARCHAR(32K) that specifies update options. The
possible values are:
v USING UPDATE MINIMUM: this setting respects the UPDATE MINIMUM
settings from the CREATE INDEX text search administration command and
the SYSTS_CREATE procedure.
v NULL or an empty string (″): the update is unconditionally started when the
procedure is called.
Authorization
Examples
Example 1: In the following example, the text search index that was created with
index_schema ’db2ts’ and index_name ’myTextIndex’ is being updated. A NULL
value in the place of the update_options means that an update is unconditionally
started when the stored procedure is called. Any error messages are requested to
be returned in English. When the procedure succeeds, the output parameter
message indicative of the successful operation is returned to the caller.
CALL SYSPROC.SYSTS_UPDATE(’db2ts’, ’myTextIndex’, ’’, ’en_US’, ?)
Return Status = 0
Usage notes
v Text search administration procedures use an existing connection to the
database. The current transaction might be committed or rolled back depending
on the completion of the procedures. As such, you might want to commit all
transaction changes to avoid any unexpected impact from such a commit or
rollback. One way to achieve this is to turn on AUTOCOMMIT.
v Multiple procedures or commands cannot be run concurrently on a text search
index if they might conflict. Some of the conflicting procedures and commands
are:
– SYSTS_ALTER procedure or ALTER INDEX db2ts command
Syntax
Procedure parameters
application_handle
An input argument of type BIGINT that specifies the application handle whose
activity is to be cancelled. If the argument is null, no activity will be found and
an SQL4702N with SQLSTATE 5U035 is returned.
uow_id
An input argument of type INTEGER that specifies the unit of work ID of the
activity that is to be cancelled. If the argument is null, no activity will be found
and an SQL4702N with SQLSTATE 5U035 is returned.
activity_id
An input argument of type INTEGER that specifies the activity ID which
Authorization
Example
Usage notes
v If no activity can be found, an SQL4702N with SQLSTATE 5U035 is returned.
v If the activity cannot be cancelled because it not in the correct state (not
initialized), an SQL4703N (reason code 1) with SQLSTATE 5U016 is returned.
v If the activity is successfully cancelled, an SQL4725N with SQLSTATE 57014 is
returned to the cancelled application.
v If, at the time of the cancel, the coordinator is processing a request for a different
activity or is idle, the activity is placed into CANCEL_PENDING state and will
be cancelled when the coordinator processes the next request for the activity.
Syntax
WLM_CAPTURE_ACTIVITY_IN_PROGRESS ( application_handle ,
uow_id , activity_id )
Procedure parameters
application_handle
An input argument of type BIGINT that specifies the application handle whose
activity is to be captured. If the argument is null, no activity will be found and
an SQL4702N with SQLSTATE 5U035 is returned.
uow_id
An input argument of type INTEGER that specifies the unit of work ID of the
Authorization
Example
Assuming that an event monitor for DB2 activities named DB2ACTIVITIES exists
and has been activated, the administrator can use the
WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES function to obtain the
application handle, unit of work ID and activity ID for the call of this stored
procedure. Assuming that the activity is identified by an application handle of 1, a
unit of work ID of 2 and an activity ID of 3, the administrator can now issue the
call to WLM_CAPTURE_ACTIVITY_IN_PROGRESS as follows:
CALL WLM_CAPTURE_ACTIVITY_IN_PROGRESS(1,2,3)
Once the procedure has completed, for an activity event monitor named
DB2ACTIVITIES, the administrator can use the following table function to find out
where the activity spent its time:
CREATE FUNCTION SHOWCAPTUREDACTIVITY(APPHNDL BIGINT,
UOWID INTEGER,
ACTIVITYID INTEGER)
RETURNS TABLE (UOW_ID INTEGER, ACTIVITY_ID INTEGER, STMT_TEXT VARCHAR(40),
LIFE_TIME DOUBLE)
LANGUAGE SQL
READS SQL DATA
NO EXTERNAL ACTION
DETERMINISTIC
RETURN WITH RAH (LEVEL, APPL_ID, PARENT_UOW_ID, PARENT_ACTIVITY_ID,
UOW_ID, ACTIVITY_ID, STMT_TEXT, ACT_EXEC_TIME) AS
(SELECT 1, ROOT.APPL_ID, ROOT.PARENT_UOW_ID,
ROOT.PARENT_ACTIVITY_ID, ROOT.UOW_ID, ROOT.ACTIVITY_ID,
ROOTSTMT.STMT_TEXT, ACT_EXEC_TIME
FROM ACTIVITY_DB2ACTIVITIES ROOT, ACTIVITYSTMT_DB2ACTIVITIES ROOTSTMT
WHERE ROOT.APPL_ID = ROOTSTMT.APPL_ID AND ROOT.AGENT_ID = APPHNDL
AND ROOT.UOW_ID = ROOTSTMT.UOW_ID AND ROOT.UOW_ID = UOWID
AND ROOT.ACTIVITY_ID = ROOTSTMT.ACTIVITY_ID AND ROOT.ACTIVITY_ID = ACTIVITYID
UNION ALL
SELECT PARENT.LEVEL +1, CHILD.APPL_ID, CHILD.PARENT_UOW_ID,
CHILD.PARENT_ACTIVITY_ID, CHILD.UOW_ID,
CHILD.ACTIVITY_ID, CHILDSTMT.STMT_TEXT, CHILD.ACT_EXEC_TIME
FROM RAH PARENT, ACTIVITY_DB2ACTIVITIES CHILD,
ACTIVITYSTMT_DB2ACTIVITIES CHILDSTMT
WHERE PARENT.APPL_ID = CHILD.APPL_ID AND
CHILD.APPL_ID = CHILDSTMT.APPL_ID AND
Usage notes
If you are using this procedure to collect activity information, input data values
will not be collected.
Syntax
WLM_COLLECT_STATS ( )
Authorization
EXECUTE privilege on the WLM_COLLECT_STATS procedure.
Examples
The WLM_COLLECT_STATS procedure only starts the collection and reset process.
It might return before the process has completed, that is, the procedure might
return to the caller before all statistics have been written to the active statistics
event monitor. Depending on how quickly the statistics collection and reset occurs,
the call to the WLM_COLLECT_STATS procedure (which is itself an activity and
will be counted in activity statistics) might be counted in either the prior collection
interval or the new collection interval that has just started.
Syntax
WLM_GET_ACTIVITY_DETAILS ( application_handle , uow_id ,
activity_id , dbpartitionnum )
Example
Usage note
Information returned
Table 182. Information returned for WLM_GET_ACTIVITY_DETAILS
Column Name Data Type Description
DBPARTITIONNUM SMALLINT Partition number from which this record was collected.
NAME VARCHAR(256) Element name. See Table 183 and Table 184 on page 617
for possible values.
VALUE VARCHAR(1024) Element values. See Table 183 and Table 184 on page 617
for possible values.
The following are returned only if the corresponding thresholds apply to the
activity.
Table 184. Elements returned if applicable
Element Name Description
CONCURRENTWORKLOADACTIVITIES_THRESHOLD_ID The ID of the threshold.
This function returns one row of statistics for each threshold queue. Statistics are
returned for queues on all active partitions.
Syntax
WLM_GET_QUEUE_STATS ( threshold_predicate , threshold_domain ,
threshold_name , threshold_id )
Authorization
Example
To see all the basic statistics for all the queues on the system, across all partitions:
SELECT substr(THRESHOLD_NAME, 1, 6) THRESHNAME,
THRESHOLD_PREDICATE,
THRESHOLD_DOMAIN,
DBPARTITIONNUM PART,
QUEUE_SIZE_TOP,
QUEUE_TIME_TOTAL,
QUEUE_ASSIGNMENTS_TOTAL QUEUE_ASSIGN
FROM table(WLM_GET_QUEUE_STATS(’’, ’’, ’’, -1)) as QSTATS
Information returned
Table 185. Information returned for WLM_GET_QUEUE_STATS
Column Name Data Type Description
THRESHOLD_PREDICATE VARCHAR(27) Threshold predicate of the threshold
responsible for this queue. The
possible values are:
v CONCDBC: concurrent database
coordinator activities threshold
v DBCONN: total database partition
connections threshold
v SCCONN: total service class
partition connections threshold
The threshold predicate values match
those of the THRESHOLDPREDICATE
column in the SYSCAT.THRESHOLDS
view.
THRESHOLD_DOMAIN VARCHAR(18) Domain of the threshold responsible
for this queue. The possible values are:
v DB: database
v SB: service subclass
v SP: service superclass
v WA: work action set
The threshold domain values match
those of the DOMAIN column in the
SYSCAT.THRESHOLDS view.
THRESHOLD_NAME VARCHAR(128) The unique name of the threshold
responsible for this queue. The
threshold name value matches that of
the THRESHOLDNAME column in the
SYSCAT.THRESHOLDS view.
THRESHOLD_ID INTEGER The unique ID of the threshold
responsible for this queue. The
threshold ID value matches that of the
THRESHOLDID column in the
SYSCAT.THRESHOLDS view.
DBPARTITIONNUM SMALLINT Partition number from which this
record was collected.
SERVICE_SUPERCLASS_NAME VARCHAR(128) Name of the service superclass that is
the domain for the threshold
responsible for this queue. Null if the
domain of the threshold is not a
service superclass or service subclass.
SERVICE_SUBCLASS_NAME VARCHAR(128) Name of the service subclass that is
the domain for the threshold
responsible for this queue. Null if the
domain of the threshold is not a
service subclass.
Syntax
WLM_GET_SERVICE_CLASS_AGENTS ( service_superclass_name ,
Authorization
Return a list of agents that are associated with application handle 1 for all database
partitions. The application handle could have been determined using the LIST
APPLICATIONS command or the
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES table function.
SELECT SUBSTR(CHAR(APPLICATION_HANDLE),1,7) AS APPHANDLE,
SUBSTR(CHAR(DBPARTITIONNUM),1,4) AS PART,
SUBSTR(CHAR(AGENT_TID),1,9) AS AGENT_TID,
SUBSTR(AGENT_TYPE,1,11) AS AGENTTYPE,
SUBSTR(AGENT_STATE,1,10) AS AGENTSTATE,
SUBSTR(REQUEST_TYPE,1,12) AS REQTYPE,
SUBSTR(CHAR(UOW_ID),1,6) AS UOW_ID,
SUBSTR(CHAR(ACTIVITY_ID),1,6) AS ACT_ID
FROM TABLE(WLM_GET_SERVICE_CLASS_AGENTS(CAST(NULL AS VARCHAR(128)),
CAST(NULL AS VARCHAR(128)), 1, -2)) AS SCDETAILS
ORDER BY APPHANDLE, PART, AGENT_TID
Usage note
The parameters have the effect of being ANDed together. That is, if one were to
specify conflicting records such as a service superclass SUP_A and subclass SUB_B
such that SUB_B is not a subclass of SUP_A, no rows would be returned.
Information returned
Table 186. Information returned by WLM_GET_SERVICE_CLASS_AGENTS
Column Name Data Type Description
SERVICE_SUPERCLASS_NAME VARCHAR(128) Name of the service superclass from which this record was
collected.
SERVICE_SUBCLASS_NAME VARCHAR(128) Name of the service subclass from which this record was
collected.
APPLICATION_HANDLE BIGINT A system-wide unique ID for the application. On a
single-partitioned database, this identifier consists of a 16 bit
counter. On a multi-partitioned database, this identifier
consists of the coordinating partition number concatenated
with a 16 bit counter. In addition, this identifier will be the
same on every partition where the application may make a
secondary connection.
DBPARTITIONNUM SMALLINT Partition number from which this record was collected.
ENTITY VARCHAR(32) If the type of entity in this row is an agent, this field shows
″db2agent″. If the type of entity in this row is a fenced mode
process, this field shows ″db2fmp (pid)″ where pid is the
process ID of the fenced mode process. Otherwise, the name
of the system entity is shown.
WORKLOAD_NAME VARCHAR(128) Name of the workload from which this record was collected.
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES -
List of workload occurrences
This function returns the list of all workload occurrences executing in a given
service class on a particular partition. A workload occurrence is a specific database
connection whose attributes match with the definition of a workload and hence is
associated with or assigned to the workload.
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES ( service_superclass_name ,
service_subclass_name , dbpartitionnum )
Authorization
Example
Assuming that the system has four database partitions and is running two
workloads at this time, the above query would produce a result like the following:
SUPERCLASS_NAME SUBCLASS_NAME PART COORDPART ...
------------------- ------------------ ---- --------- ...
SYSDEFAULTMAINTENAN SYSDEFAULTSUBCLASS 0 0 ...
SYSDEFAULTSYSTEMCLA SYSDEFAULTSUBCLASS 0 0 ...
Usage note
The parameters have the effect of being ANDed together. That is, if one were to
specify conflicting records such as a service superclass SUP_A and subclass SUB_B
such that SUB_B is not a subclass of SUP_A, no rows would be returned.
Information returned
Table 187. Information returned for WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES
Column Name Data Type Description
SERVICE_SUPERCLASS_NAME VARCHAR(128) Name of the service superclass from which this
record was collected.
SERVICE_SUBCLASS_NAME VARCHAR(128) Name of the service subclass from which this
record was collected.
DBPARTITIONNUM SMALLINT Partition number from which this record was
collected.
COORD_PARTITION_NUM SMALLINT Partition number of the coordinator partition of
the given workload occurrence.
APPLICATION_HANDLE BIGINT A system-wide unique ID for the application.
On a single-partitioned database, this identifier
consists of a 16 bit counter. On a
multi-partitioned database, this identifier
consists of the coordinating partition number
concatenated with a 16 bit counter. In addition,
this identifier will be the same on every
partition where the application may make a
secondary connection.
WORKLOAD_NAME VARCHAR(128) Name of the workload from which this record
was collected.
Syntax
WLM_GET_SERVICE_SUBCLASS_STATS ( service_superclass_name ,
service_subclass_name , dbpartitionnum )
Authorization
Examples
Example 1: Since every activity has to be mapped to a DB2 Service Class prior to
being executed, the global state of the system can be regularly monitored using the
service class statistics table functions and querying all the service classes on all the
partitions (note that passing a null value for an argument is saying to not restrict
the result by that argument, except for the last argument, dbpartitionnum, where
-2 means that data from all database partitions are to be returned). The following
statement returns service class statistics such as average activity lifetime and
standard deviation in seconds:
SELECT SUBSTR(SERVICE_SUPERCLASS_NAME,1,19) AS SUPERCLASS_NAME,
SUBSTR(SERVICE_SUBCLASS_NAME,1,18) AS SUBCLASS_NAME,
SUBSTR(CHAR(DBPARTITIONNUM),1,4) AS PART,
CAST(COORD_ACT_LIFETIME_AVG / 1000 AS DECIMAL(9,3))
AS AVGLIFETIME,
CAST(COORD_ACT_LIFETIME_STDDEV / 1000 AS DECIMAL(9,3))
AS STDDEVLIFETIME,
SUBSTR(CAST(LAST_RESET AS VARCHAR(30)),1,16) AS LAST_RESET
FROM TABLE(WLM_GET_SERVICE_SUBCLASS_STATS(CAST(NULL AS VARCHAR(128)),
CAST(NULL AS VARCHAR(128)), -2)) AS SCSTATS
ORDER BY SUPERCLASS_NAME, SUBCLASS_NAME, PART
Example 2: The same table function can also give the highest value for average
concurrency of coordinator activities running in the service class on each partition.
SELECT SUBSTR(SERVICE_SUPERCLASS_NAME,1,19) AS SUPERCLASS_NAME,
SUBSTR(SERVICE_SUBCLASS_NAME,1,18) AS SUBCLASS_NAME,
SUBSTR(CHAR(DBPARTITIONNUM),1,4) AS PART,
CONCURRENT_ACT_TOP AS ACTTOP,
CONCURRENT_WLO_TOP AS CONNTOP
The output of this table function will give the administrator a good high level view
of the ″load″ on each partition for a specific database by checking the average
execution times and numbers of activities. Any significant variations of the high
level gauges returned by these table functions may indicate a change in the load
on the system.
Usage notes
The parameters have the effect of being ANDed together. That is, if one were to
specify conflicting records such as a superclass name SUPA and subclass name
SUBB such that SUBB is not a subclass of SUPA, no rows would be returned.
Information returned
Table 188. Information returned for WLM_GET_SERVICE_SUBCLASS_STATS
Column Name Data Type Description
SERVICE_SUPERCLASS_NAME VARCHAR(128) Name of the service superclass from which
this record was collected.
SERVICE_SUBCLASS_NAME VARCHAR(128) Name of the service subclass from which this
record was collected.
DBPARTITIONNUM SMALLINT Partition number from which this record was
collected.
Syntax
WLM_GET_SERVICE_SUPERCLASS_STATS ( service_superclass_name ,
dbpartitionnum )
Authorization
Example
To see all the basic statistics for all the service superclasses on the system, across
all database partitions:
SELECT SUBSTR(SERVICE_SUPERCLASS_NAME, 1, 26) SERVICE_SUPERCLASS_NAME,
DBPARTITIONNUM,
LAST_RESET,
CONCURRENT_CONNECTION_TOP CONCURRENT_CONN_TOP
FROM TABLE(WLM_GET_SERVICE_SUPERCLASS_STATS(’’, -2)) as SCSTATS
Usage note
The WLM_GET_SERVICE_SUPERCLASS_STATS table function returns one row of
data per service superclass and per partition. No aggregation across service
superclasses (on a partition), or across partitions (for a service superclass or more)
is performed. However, aggregation can be achieved through SQL queries as
shown in the example above.
Information returned
Table 189. Information returned for WLM_GET_SERVICE_SUPERCLASS_STATS
Column Name Data Type Description
SERVICE_SUPERCLASS_NAME VARCHAR(128) Name of the service superclass from which this
record was collected.
DBPARTITIONNUM SMALLINT Partition number from which this record was
collected.
Syntax
WLM_GET_WORK_ACTION_SET_STATS ( work_action_set_name ,
dbpartitionnum )
Authorization
Assume that there are three work classes, ReadClass, WriteClass, and LoadClass.
There is a work action associated with ReadClass and a work action associated
with LoadClass, but there is no work action associated with WriteClass. On
partition 0, there are 8 activities currently executing (or queued) in the ReadClass,
4 activities currently executing (or queued) in the WriteClass, 2 activities currently
executing (or queued) in the LoadClass, and 3 activities currently executing (or
queued) that have not been assigned to any work class. Because there is no work
action associated with the WriteClass work class, the 4 activities to which it applies
are counted in the artificial “*” class along with the 3 activities that were not
assigned to any work class.
SELECT SUBSTR(WORK_ACTION_SET_NAME,1,18) AS WORK_ACTION_SET_NAME,
SUBSTR(CHAR(DBPARTITIONNUM),1,4) AS PART,
SUBSTR(WORK_CLASS_NAME,1,15) AS WORK_CLASS_NAME,
LAST_RESET,
SUBSTR(CHAR(WLO_ACT_TOTAL),1,14) AS TOTAL_WLO_ACTS
FROM TABLE(WLM_GET_WORK_ACTION_SET_STATS
(CAST(NULL AS VARCHAR(128)), -2)) AS WASSTATS
ORDER BY WORK_ACTION_SET_NAME, WORK_CLASS_NAME, PART
Information returned
Table 190. Information returned for WLM_GET_WORK_ACTION_SET_STATS
Column Name Data Type Description
WORK_ACTION_SET_NAME VARCHAR(128) The name of the work action set.
DBPARTITIONNUM SMALLINT Partition number from which this record was collected.
LAST_RESET TIMESTAMP Time when statistics were last reset. There are four events
that can occur that will trigger a reset of statistics, which
will update this timestamp:
v The WLM_COLLECT_STATS procedure is called.
v The periodic collection and reset process controlled by
the WLM_COLLECT_INT configuration parameter
causes a collection and reset.
v The database is reactivated.
v The work action set for which statistics are being
reported was modified and the change was committed.
The LAST_RESET timestamp is in local time.
WORK_CLASS_NAME VARCHAR(128) The name of the work class related to the given work
action set. There must be a work action associated with
this work class for it to appear in this table. “*” represents
an artificial work class created to count all those activities
that did not belong to the other work classes for which
the user associated one or more work actions.
WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES - Return
a list of activities
This function returns the list of all activities that were submitted through the given
application on the specified partition and have not yet completed.
Syntax
WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES ( application_handle ,
dbpartitionnum )
Authorization
Example
Once an application handle is identified, it is possible to look up all the activities
currently running in this application. For example, suppose an administrator
wishes to list the activities of an application whose application handle, determined
using the list applications command, was found to be 1:
SELECT SUBSTR(CHAR(COORD_PARTITION_NUM),1,5) AS COORD,
SUBSTR(CHAR(DBPARTITIONNUM),1,4) AS PART,
SUBSTR(CHAR(UOW_ID),1,5) AS UOWID,
SUBSTR(CHAR(ACTIVITY_ID),1,5) AS ACTID,
SUBSTR(CHAR(PARENT_UOW_ID),1,8) AS PARUOWID,
SUBSTR(CHAR(PARENT_ACTIVITY_ID),1,8) AS PARACTID,
ACTIVITY_TYPE AS ACTTYPE,
SUBSTR(CHAR(NESTING_LEVEL),1,7) AS NESTING
FROM TABLE(WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES(1, -2)) AS WLOACTS
ORDER BY PART, UOWID, ACTID
Information returned
Table 191. Information returned by WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES
Column Name Data Type Description
APPLICATION_HANDLE BIGINT A system-wide unique ID for the
application. On a single-partitioned
database, this identifier consists of a 16 bit
counter. On a multi-partitioned database,
this identifier consists of the coordinating
partition number concatenated with a 16 bit
counter. In addition, this identifier will be
the same on every partition where the
application may make a secondary
connection.
DBPARTITIONNUM SMALLINT Partition number from which this record
was collected.
COORD_PARTITION_NUM SMALLINT The coordinator partition of the activity.
LOCAL_START_TIME TIMESTAMP The time that this activity began doing work
on the partition. It is in local time. This field
can be null when an activity has entered the
system but is in a queue and has not started
executing.
UOW_ID INTEGER Unique unit of work identifier within an
application. Refers to the original unit of
work that the activity started in.
ACTIVITY_ID INTEGER Unique activity ID within a unit of work.
PARENT_UOW_ID INTEGER Unique unit of work identifier within an
application. Refers to the original unit of
work that the activity’s parent activity
started in. Returns null if the activity has no
parent activity or at remote partition.
PARENT_ACTIVITY_ID INTEGER Unique activity identifier within a unit of
work for the parent of the activity whose ID
is ACTIVITY_ID. Returns null if the activity
has no parent activity or at remote partition.
Syntax
WLM_GET_WORKLOAD_STATS ( workload_name , dbpartitionnum )
Authorization
Example
An administrator may want to look at the statistics for workloads. She could do so
using the following query:
SELECT SUBSTR(WORKLOAD_NAME,1,22) AS WL_DEF_NAME,
SUBSTR(CHAR(DBPARTITIONNUM),1,4) AS PART,
CONCURRENT_WLO_TOP AS WLO_TOP,
CONCURRENT_WLO_ACT_TOP AS WLO_ACT_TOP
FROM TABLE(WLM_GET_WORKLOAD_STATS(CAST(NULL AS VARCHAR(128)), -2))
AS WLSTATS
ORDER BY WL_DEF_NAME, PART
Usage note
This function returns one row for every combination of workload name and
database partition number. No aggregation across workloads or across partitions or
across service classes is performed. However, aggregation can be achieved through
SQL queries.
Information returned
Table 192. Information returned by WLM_GET_WORKLOAD_STATS
Column Name Data Type Description
WORKLOAD_NAME BIGINT Name of the workload from which this record was
collected.
DBPARTITIONNUM SMALLINT Partition number from which this record was
collected
LAST_RESET TIMESTAMP Time when statistics were last reset. There are four
events that can occur that will trigger a reset of
statistics, which will update this timestamp:
v The WLM_COLLECT_STATS procedure is called.
v The periodic collection and reset process controlled
by the WLM_COLLECT_INT configuration
parameter causes a collection and reset.
v The database is reactivated.
v The workload for which statistics are being
reported was modified and the change was
committed.
The LAST_RESET timestamp is in local time.
CONCURRENT_WLO_TOP INTEGER Highest number of concurrent occurrences of the
given workload on this partition since the last reset.
CONCURRENT_WLO_ACT_TOP INTEGER Highest number of concurrent activities (including
both coordinator and nested) in either executing
(which includes idle and waiting) or queued state that
has been reached in any occurrence of this workload
since last reset. Updated by each workload occurrence
at the end of its unit of work.
COORD_ACT_COMPLETED_TOTAL BIGINT The total number of coordinator activities at any
nesting level assigned to any occurrence of this
workload that completed since the last reset. Updated
by each workload occurrence at the end of its unit of
work.
COORD_ACT_ABORTED_TOTAL BIGINT The total number of coordinator activities at any
nesting level assigned to any occurrence of this
workload that were aborted prior to completion since
the last reset. Updated by each workload occurrence
at the end of its unit of work.
By using this procedure, the application can set the client’s user ID, application
name, workstation name, accounting, or workload information at the DB2 server.
Invoking this procedure results in changes at the DB2 server to the values stored
for this connection of the relevant transaction processor (TP) monitor client
information fields and special register settings.
The client information fields are used at the DB2 server for determining the
identity of the application or end-user currently using the connection. The client
information fields for a connection are considered during DB2 workload evaluation
and also appear in any DB2 audit records or application snapshot generated for
this connection.
Unlike the sqleseti API, this procedure does not set client information at the client
but sets the corresponding client attributes at the DB2 server. Therefore, the sqleqry
API cannot be used to query the client information that is set at the DB2 server
using this procedure.
The data values provided with the procedure are converted to the database code
page before being stored in the related TP Monitor fields or special registers. Any
data value that exceeds the maximum supported size after conversion to the
database code page will be truncated before being stored at the server. These
truncated values will be returned by both the TP Monitor fields and the special
registers.
Syntax
WLM_SET_CLIENT_INFO ( client_userid , client_wrkstnname ,
Procedure parameters
client_userid
An input argument of type VARCHAR(255) that specifies the user ID for the
client. If NULL is specified, the value remains unchanged. If an empty string
(″) is specified, the user ID for the client is reset to the default value, which is
blank.
client_wrkstnname
An input argument of type VARCHAR(255) that specifies the workstation
name for the client. If NULL is specified, the value remains unchanged. If an
empty string (″) is specified, the workstation name for the client is reset to the
default value, which is blank.
client_applname
An input argument of type VARCHAR(255) that specifies the application name
for the client. If NULL is specified, the value remains unchanged. If an empty
string (″) is specified, the application name for the client is reset to the default
value, which is blank.
client_acctstr
An input argument of type VARCHAR(255) that specifies the accounting string
for the client. If NULL is specified, the value remains unchanged. If an empty
string (″) is specified, the accounting string for the client is reset to the default
value, which is blank.
client_workload
An input argument of type VARCHAR(255) that specifies the workload
assignment mode for the client. If NULL is specified, the value remains
unchanged. The valid values are:
v SYSDEFAULTADMWORKLOAD: Specifies that the database connection will
be assigned to the SYSDEFAULTADMWORKLOAD, allowing users with
DBADM or SYSADM authority to bypass the normal workload evaluation.
v AUTOMATIC: Specifies that the database connection will be assigned to a
workload chosen by the workload evaluation that is performed
automatically by the server.
Examples
Set the user ID, workstation name, application name, accounting string, and
workload assignment mode for the client.
CALL SYSPROC.WLM_SET_CLIENT_INFO(’db2user’, ’machine.torolab.ibm.com’,
’auditor’, ’Accounting department’, ’AUTOMATIC’)
Set the user ID to db2user2 for the client without setting the other client attributes.
CALL SYSPROC.WLM_SET_CLIENT_INFO(’db2user2’, NULL, NULL, NULL, NULL)
Reset the user ID for the client to blank without modifying the values of the other
client attributes.
CALL SYSPROC.WLM_SET_CLIENT_INFO(’’, NULL, NULL, NULL, NULL)
Syntax
ADMIN_COPY_SCHEMA ( sourceschema , targetschema , copymode ,
Procedure parameters
sourceschema
An input argument of type VARCHAR(128) that specifies the name of the
schema whose objects are being copied. The name is case-sensitive.
targetschema
An input argument of type VARCHAR(128) that specifies a unique schema
name to create the copied objects into. The name is case-sensitive. If the
schema name already exists, the procedure call will fail and return a message
indicating that the schema must be removed prior to invoking the procedure.
copymode
An input argument of type VARCHAR(128) that specifies the mode of copy
operation. Valid options are:
v ’DDL’: create empty copies of all supported objects from the source schema.
Authorization
In order for the schema copy to be successful, the user ID calling this procedure
must have the appropriate object creation authorities including both the authority
to select from the source tables, and the authority to perform a load. If a table in
the source schema is protected by label based access control (LBAC), the user ID
must have LBAC credentials that allow creating that same protection on the target
table. If copying with data, the user ID must also have LBAC credentials that allow
both reading the data from the source table and writing that data to the target
table.
Example
CALL SYSPROC.ADMIN_COPY_SCHEMA(’SOURCE_SCHEMA’, ’TARGET_SCHEMA’,
’COPY’, NULL, ’SOURCETS1 , SOURCETS2’, ’TARGETTS1, TARGETTS2,
SYS_ANY’, ’ERRORSCHEMA’, ’ERRORNAME’)
Restrictions
v Only DDL copymode is supported for HADR databases.
v XML with COPY or COPY NO is not supported.
v Using the ADMIN_COPY_SCHEMA procedure with the COPYNO option places
the table spaces in which the target database object resides in backup pending
state. After the load operation completes, target schema tables are in set integrity
pending state, and the ADMIN_COPY_SCHEMA procedure issues a SET
INTEGRITY statement to get the tables out of this state. Because the table spaces
are already in backup pending state, the SET INTEGRITY statement fails. For
information on how to resolve this problem, see “Copying a schema”.
Transactional considerations
v If the ADMIN_COPY_SCHEMA procedure is forced to rollback due to a
deadlock or lock timeout during its processing, any work performed in the unit
of work that called the ADMIN_COPY_SCHEMA procedure is also rolled back.
v If a failure occurs during the DDL phase of the copy, all the changes that were
made to the target schema are rolled back to a savepoint.
v If copymode is set to ’COPY’ or ’COPYNO’, the ADMIN_COPY_SCHEMA
procedure commits once the DDL phase of the copy is complete, also
committing any work done in the unit of work that called the procedure.
Syntax
ADMIN_DROP_SCHEMA ( schema , dropmode , errortabschema ,
errortab )
Procedure parameters
schema
An input argument of type VARCHAR(128) that specifies the name of the
schema being dropped. The name must be specified in uppercase characters.
dropmode
Reserved for future use and should be set to NULL.
errortabschema
An input and output argument of type VARCHAR(128) that specifies the
schema name of a table containing error information for objects that could not
be dropped. The name is case-sensitive. This table is created for the user by the
ADMIN_DROP_SCHEMA procedure in the SYSTOOLSPACE table space. If no
errors occurred, then this parameter is NULL on output.
errortab
An input and output argument of type VARCHAR(128) that specifies the name
of a table containing error information for objects that could not be dropped.
The name is case-sensitive. This table is created for the user by the
ADMIN_DROP_SCHEMA procedure in the SYSTOOLSPACE table space. This
table is owned by the user ID that invoked the procedure. If no errors
occurred, then this parameter is NULL on output. If the table cannot be created
or already exists, the procedure operation fails and an error message is
returned. The table must be cleaned up by the user following any call to
ADMIN_DROP_SCHEMA; that is, the table must be dropped in order to
reclaim the space it is consuming in SYSTOOLSPACE.
Authorization
Drop authority is needed on all objects being removed for the user calling this
procedure.
Example
CALL SYSPROC.ADMIN_DROP_SCHEMA(’SCHNAME’, NULL, ’ERRORSCHEMA’, ’ERRORTABLE’)
Return Status = 0
The return status is not zero only when an internal error has been detected (for
example, if SYSTOOLSPACE does not exist).
Usage notes
v If objects in another schema depend on an object being dropped, the default
DROP statement semantics apply.
v This procedure does not support dropping the following objects:
– index extensions
– nicknames
– packages
– typed tables
ALTOBJ
The ALTOBJ procedure parses an input CREATE TABLE statement serving as the
target data definition language (DDL) for an existing table that is to be altered.
This procedure supports the following alter table operations and maintains
recoverable dependencies:
v Renaming a column
v Increasing or decreasing the size of a column
v Altering a column type and transforming existing data using DB2 scalar
functions
v Changing the precision or the scale of decimal values
v Changing the default value of a column
v Changing the nullability attribute of a column to nullable
v Dropping a column
Syntax
ALTOBJ ( exec-mode , sql-stmt , alter-id , msg )
Procedure parameters
exec-mode
An input argument of type VARCHAR(30) that specifies one of the following
execution modes:
’GENERATE’
Specifies that all the scripts required by the VALIDATE, APPLY, and
UNDO modes are to be generated.
’VALIDATE’
Specifies that the statement syntax is to be validated. This option also
generates a script to manage the processing of related objects and
relationships for the table that is to be altered.
’APPLY_CONTINUE_ON_ERROR’ or ’APPLY_STOP_ON_ERROR’
Specifies that a script to manage the processing of related objects and
relationships for the table that is to be altered is to be generated. Data
from the original table is to be exported, transformed, and used to
populate the new table.
Authorization
Examples
Example 1: Run the ALTOBJ procedure to alter column CL2 in table T1 from type
INTEGER to BIGINT. The original data definition language for table T1 is:
CREATE TABLE T1 (CL1 VARCHAR(5), CL2 INTEGER)
The ALTOBJ procedure call to alter the column data type is:
CALL SYSPROC.ALTOBJ(’APPLY_CONTINUE_ON_ERROR’,
’CREATE TABLE T1 (CL1 VARCHAR(5), CL2 BIGINT)’, -1, ?)
Note: If you see the following error, try to increase the APPLHEAPSZ parameter
value:
SQL0443N Routine ″SYSPROC.ALTOBJ″ (specific name ″ALTOBJ″) has returned an
error SQLSTATE with diagnostic text ″SQL0954 ″. SQLSTATE=38553
Example 2: Run the ALTOBJ procedure in VALIDATE mode with alter-id input.
CALL SYSPROC.ALTOBJ(’VALIDATE’, CAST (NULL AS VARCHAR(2048)), 123, ?)
Usage notes
This procedure does not support the following alter table operations:
v Altering materialized query tables (MQTs) is not supported. Altering a table
which contains an MQT is supported.
v Altering typed tables is not supported.
v Altering a remote table using a nickname is not supported.
If a table is altered using the ALTOBJ procedure, and the table has an MQT
defined, the MQT will be created, but it will not be populated with data.
If a table is altered using the ALTOBJ procedure, and the table has an MQT
defined, any columns that are not part of the select result from the table being
altered are lost because the MQT content is rebuilt from the new base table.
The definition of the objects might change between ALTOBJ procedure calls
because there are no object locks that persist through different sessions.
The table profiles (such as runstats profile) that are associated with the table are
lost after going through this extensive alter process.
The SYSTOOLSPACE is used for the routine’s operation tables to store metadata;
that is, data used to describe database objects and their operation.
APPLICATION_ID
The APPLICATION_ID function returns the application ID of the current
connection. The data type of the result is VARCHAR(128).
The value returned by the function is unique within a 100-year interval and valid
only for the duration of the connection established before calling the function.
Syntax
APPLICATION_ID ( )
Syntax
COMPILATION_ENV ( compilation-env )
The function returns a table of two columns (see Table 195 on page 658): NAME
VARCHAR(256) and VALUE VARCHAR(1024). The possible values for the
compilation environment element names are described in Table 196 on page 658.
The origin of the element values depends primarily on whether the SQL statement
is issued dynamically or bound as part of a package.
The number and types of entries in a compilation environment can change over
time as capabilities are added to the DB2 database manager. If the compilation
environment is from a different DB2 database manager level than the level on
which this function is executing, only those elements that are recognized by the
level of the function are returned. The descriptions of the elements might also vary
from release to release.
Examples
Example 1: Request all the elements of a specific compilation environment that was
previously captured by a deadlock event monitor. A deadlock event monitor that is
created specifying the WITH DETAILS HISTORY option will capture the
compilation environment for dynamic SQL statements. This captured environment
is what is accepted as input to the table function.
SELECT NAME, VALUE
FROM TABLE(SYSPROC.COMPILATION_ENV(:hv1)) AS t
Authorization
Example
7 record(s) selected.
Usage note
Authorization
Example
4 record(s) selected.
Usage note
Information returned
Table 198. Information returned by the CONTACTS administrative view
Column name Data type Description
NAME VARCHAR(128) Name of contact.
Authorization
SELECT or CONTROL privilege on the DB_HISTORY administrative view and
EXECUTE privilege on the ADMIN_LIST_HIST table function.
Example
Select the database partition number, entry ID, operation, start time, and status
information from the database history files for all the database partitions of the
database to which the client is currently connected.
SELECT DBPARTITIONNUM, EID, OPERATION, START_TIME, ENTRY_STATUS
FROM SYSIBMADM.DB_HISTORY
1 record(s) selected.
Information returned
Table 199. Information returned by the DB_HISTORY administrative view
Column name Data type Description
DBPARTITIONNUM SMALLINT Database partition number.
EID BIGINT Number that uniquely
identifies an entry in the
history file.
START_TIME VARCHAR(14) Timestamp marking the start
of a logged event.
Authorization
11 record(s) selected.
Information returned
Table 201. Information returned by the DBPATHS administrative view
Column name Data type Description
DBPARTITIONNUM SMALLINT Database partition number.
TYPE VARCHAR(64) Describes the type of
database object that the path
belongs to. For example the
path to the log directory
indicated by the LOGPATH
database configuration
parameter would be shown
in this column as LOGPATH.
See Table 202 on page 667 for
a list of possible return
values.
v For table spaces using automatic storage, both used and unused storage paths are
returned. The unused automatic storage paths are needed in case the split mirror backup
is restored. Consider the following example: A split mirror backup is taken on a
production system. After the backup completes, the automatic storage paths that were not
in use before the backup are now in use in production. Assume that there is now a need
to restore the split mirror backup. At this point, it is necessary to roll forward the logs
from the production database. In order to roll forward the logs, all of the automatic
storage paths are required since all automatic storage paths are now in use.
v Table space containers managed by automatic storage are not returned individually.
Instead, they are reflected in the automatic storage path column.
v The automatic storage paths are returned once per database partition.
v The values returned for LOGPATH and MIRRORLOGPATH are the values stored in
memory. Changed values stored on disk, which are only applicable after a database
restart, are not returned.
v If output from SELECT * FROM SYSIBMADM.DBPATHS is being used to create a db2relocatedb
configuration file (a file containing the configuration information necessary for relocating
a database), the DBPATH output must be modified appropriately before it can be used in
the configuration file.
For example, the following DBPATH output:
/storage/svtdbm3/svtdbm3/NODE0000/SQL00001/
Restriction
EXPLAIN_FORMAT_STATS
This new scalar function is used to display formatted statistics information which
is parsed and extracted from explain snapshot captured for a given query. The data
type of the result is CLOB(50M).
Syntax
EXPLAIN_FORMAT_STATS ( snapshot )
Authorization
Example
SELECT EXPLAIN_FORMAT_STATS(SNAPSHOT)
FROM EXPLAIN_STATEMENT
WHERE EXPLAIN_REQUESTER = ’DB2USER1’ AND
EXPLAIN_TIME = timestamp(’2006-05-12-14.38.11.109432’) AND
SOURCE_NAME = ’SQLC2F0A’ AND
SOURCE_SCHEMA = ’NULLID’ AND
SOURCE_VERSION = ’’ AND
EXPLAIN_LEVEL = ’O’ AND
STMTNO = 1 AND
SECTNO = 201
Column Statistics:
------------------
Schema name of the column type: SYSIBM
Name of column type: INTEGER
Maximum column length: 4
Scale for decimal column: 0
Number of distinct column values: 4
Average column length: 5
Number of most frequent values: 1
Number of quantiles: 5
Second highest data value: 3
Second lowest data value: 2
Column sequence in partition key: 0
Average number of sub-elements: -1
Average length of delimiters: -1
Quantile Statistics:
Valcount Distcount Value
----------------------------------
0 1 1
2 1 1
3 2 2
4 3 3
5 4 4
Column Information:
--------------------
Number: 2
Name: C2
Statistics Available: Yes
Column Statistics:
------------------
Schema name of the column type: SYSIBM
Name of column type: INTEGER
Maximum column length: 4
Scale for decimal column: 0
Number of distinct column values: 4
Average column length: 5
Number of most frequent values: 1
Number of quantiles: 5
Second highest data value: 3
Second lowest data value: 2
Column sequence in partition key: 0
Average number of sub-elements: -1
Average length of delimiters: -1
Column Information:
Column Statistics:
------------------
Schema name of the column type: SYSIBM
Name of column type: INTEGER
Maximum column length: 4
Scale for decimal column: 0
Number of distinct column values: 2
Average column length: 5
Number of most frequent values: -1
Number of quantiles: 2
Second highest data value: 2
Second lowest data value: 1
Column sequence in partition key: 0
Average number of sub-elements: -1
Average length of delimiters: -1
Column Information:
--------------------
Number: 2
Name: C2
Statistics Available: Yes
Column Statistics:
------------------
Schema name of the column type: SYSIBM
Name of column type: INTEGER
Maximum column length: 4
Scale for decimal column: 0
Number of distinct column values: 2
Average column length: 5
Number of most frequent values: -1
Number of quantiles: 2
Second highest data value: 2
Second lowest data value: 1
Column sequence in partition key: 0
Average number of sub-elements: -1
Average length of delimiters: -1
EXPLAIN_GET_MSGS
EXPLAIN_GET_MSGS ( explain-requester , explain-time , source-name ,
locale )
Any of the following input arguments can be null. If an argument is null, it is not
used to limit the query.
explain-requester
An input argument of type VARCHAR(128) that specifies the authorization ID
of the initiator of this Explain request. A null value excludes this parameter
from the search condition of the query.
explain-time
An input argument of type TIMESTAMP that specifies the time of initiation for
the Explain request. A null value excludes this parameter from the search
condition of the query.
source-name
An input argument of type VARCHAR(128) that specifies the name of the
package running when the dynamic statement was explained, or the name of
the source file when the static SQL statement was explained. A null value
excludes this parameter from the search condition of the query.
source-schema
An input argument of type VARCHAR(128) that specifies the schema, or
Example
Request formatted English messages from the Explain tables in the default schema
for requester SIMMEN that were generated in the last hour. Specify a source name
of SQLC2E03.
SELECT MSG
FROM TABLE(EXPLAIN_GET_MSGS(
’SIMMEN’,
CAST(NULL AS TIMESTAMP),
’SQLC2E03’,
CAST(NULL AS VARCHAR(128)),
CAST(NULL AS VARCHAR(64)),
CAST(NULL AS CHAR(1)),
CAST(NULL AS INTEGER),
CAST(NULL AS INTEGER),
’en_US’))
AS REGISTRYINFO
WHERE EXPLAIN_TIME >= (CURRENT TIMESTAMP - 1 HOUR)
ORDER BY DIAGNOSTIC_ID
GET_DBSIZE_INFO
The GET_DBSIZE_INFO procedure calculates the database size and maximum
capacity.
Syntax
GET_DBSIZE_INFO ( snapshot-timestamp , dbsize , dbcapacity ,
refresh-window )
Procedure parameters
snapshot-timestamp
An output parameter of type TIMESTAMP that returns the time at which dbsize
and dbcapacity were calculated. This timestamp, along with the value of
Authorization
v SYSMON authority
v EXECUTE privilege on the GET_DBSIZE_INFO procedure
Examples
Example 1: Get the database size and capacity using a default refresh window of 30
minutes. The database size and capacity will be recalculated when the cached data
is older than 30 minutes.
CALL GET_DBSIZE_INFO(?, ?, ?, -1)
Return Status = 0
Example 2: Get the database size and capacity using a refresh window of 0 minutes.
The database size and capacity will be recalculated immediately.
CALL GET_DBSIZE_INFO(?, ?, ?, 0)
Return Status = 0
Example 3: Get the database size and capacity using a refresh window of 24 hours.
The database size and capacity will be recalculated when the cached data is older
than 1440 minutes.
CALL GET_DBSIZE_INFO(?, ?, ?, 1440)
Return Status = 0
Usage notes
The calculated values are returned as procedure output parameters and are cached
in the SYSTOOLS.STMG_DBSIZE_INFO table. The procedure caches these values
because the calculations are costly. The SYSTOOLS.STMG_DBSIZE_INFO table is
created automatically the first time the procedure executes. If there are values
cached in the SYSTOOLS.STMG_DBSIZE_INFO table and they are current enough,
as determined by the snapshot-timestamp and refresh-window values, these cached
values are returned. If the cached values are not current enough, new cached
values are calculated, inserted into the SYSTOOLS.STMG_DBSIZE_INFO table and
returned, and the snapshot-timestamp value is updated.
To ensure that the data is returned by all partitions for a global table space
snapshot, the database must be activated.
The SYSTOOLSPACE is used for the routine’s operation tables to store metadata;
that is, data used to describe database objects and their operation.
Authorization
Example
Chapter 3. Supported routines and views 677
Retrieve all contacts that will receive notification of health alerts.
SELECT * FROM SYSIBMADM.NOTIFICATIONLIST
3 record(s) selected.
Information returned
Table 204. Information returned by the NOTIFICATIONLIST administrative view
Column name Data type Description
NAME VARCHAR(128) Name of contact.
TYPE VARCHAR(7) Type of contact:
v ’CONTACT’
v ’GROUP’
Syntax
Authorization
Example
SELECT FACILITY, RECTYPE, TIMESTAMP, IMPACT, SUBSTR(MSG,1, 50) AS MSG
FROM TABLE (PD_GET_DIAG_HIST( ’MAIN’, ’E’, ’’, CAST (NULL AS TIMESTAMP),
CAST (NULL AS TIMESTAMP) ) ) AS T
WHERE T.PROCESS_NAME = ’db2star2’ OR T.PROCESS_NAME = ’db2stop2’
Information returned
Table 205. Information returned by the PD_GET_DIAG_HIST table function
Column Name Data Type Description
FACILITY VARCHAR(20) A facility is a logical grouping which records relate to.
The possible values are:
v ALL: Returns records from all facilities
v MAIN: Returns records from the DB2 general
diagnostic logs. This currently means db2diag.log,
admin notification log and rotating event logs
v OPTSTATS: Return records related to optimizer
statistics
RECTYPE VARCHAR(3) The type of record. The possible values are:
v ’DI’: Internal diagnostic record
v ’DX’: External diagnostic record
v ’EI’: Internal event record
v ’EX’: External event record
TIMESTAMP TIMESTAMP The time that the message was created.
TIMEZONE INTEGER The time difference (in minutes) from the Universal
Coordinated Time (UCT). For example, -300 is EST.
INSTANCENAME VARCHAR(128) The name of the instance where the message was
created.
DBPARTITIONNUM SMALLINT The partition number where the message was created.
For non-partitioned database, 0 is returned.
LEVEL CHAR(1) The severity level of the record. The possible values are:
v ’C’: Critical
v ’E’: Error
v ’ I’: Informational
v ’S’: Severe
v ’W’: Warning
IMPACT VARCHAR(18) Qualifies the impact of this message from a user’s
perspective. This clarifies the impact of the message on
the business process DB2 is part of. The possible values
are:
v ’CRITICAL’
v ’IMMEDIATE’
v ’NONE’
v ’POTENTIAL’
v ’UNLIKELY’
DBNAME VARCHAR(128) The name of the database being accessed while this
message was created.
EDU_ID BIGINT The Engine Dispatched Unit identifier that created this
message.
Refer to Table 206 on page 690 for a complete list of information that can be
returned.
Example
Get all critical log messages logged in the last 24 hours, ordered by most recent.
SELECT * FROM SYSIBMADM.PDLOGMSGS_LAST24HOURS
WHERE MSGSEVERITY = ’C’ ORDER BY TIMESTAMP DESC
4 record(s) selected.
Refer to Table 206 on page 690 for a complete list of information that can be
returned.
Syntax
PD_GET_LOG_MSGS ( oldest_timestamp )
Authorization
Examples
Example 2: Retrieve all critical errors logged on instance DB2 for database partition
0 in the last day, sorted by most recent.
SELECT TIMESTAMP, DBNAME, MSG
FROM TABLE (PD_GET_LOG_MSGS(CURRENT_TIMESTAMP - 1 DAYS)) AS T
WHERE MSGSEVERITY = ’C’ AND INSTANCENAME = ’DB2’ AND
DBPARTITIONNUM = 0
ORDER BY TIMESTAMP DESC
2 record(s) selected.
...
Example 4: Find all instances of message ADM0504C in the notification log. Note
that the messages considered are not limited by a timestamp. This could be an
expensive operation if the notification logfile is very large.
SELECT TIMESTAMP, DBPARTITOINNUM, DBNAME, MSG
FROM TABLE (PD_GET_LOG_MSGS(CAST(NULL AS TIMESTAMP))) AS T
WHERE MSGNUM = 504 AND MSGTYPE = ’ADM’ AND MSGSEVERITY = ’C’
Information returned
Note: In a partitioned database environment, the order in which log messages are
returned cannot be guaranteed. If the order of log records is important, the results
should be sorted by timestamp.
Table 206. Information returned by the PDLOGMSGS_LAST24HOURS administrative view
and the PD_GET_LOG_MSGS table function
Column name Data type Description
TIMESTAMP TIMESTAMP The time when the entry was
logged.
TIMEZONE INTEGER Time difference (in minutes)
from Universal Coordinated
Time (UCT). For example,
-300 is EST.
Syntax
REORGCHK_IX_STATS ( scope , criteria )
Procedure parameters
scope
An input argument of type CHAR(1) that specifies the scope of the tables that
are to be evaluated, using one of the following values:
’T’ Table
’S’ Schema
criteria
An input argument of type VARCHAR(259). If scope has a value of ’T’, specifies
a fully qualified table name, or accepts one of the following values: ALL,
USER, or SYSTEM. If scope has a value of ’S’, specifies a schema name.
Authorization
v SELECT privilege on catalog tables.
v EXECUTE privilege on the REORGCHK_IX_STATS procedure.
Example
CALL SYSPROC.REORGCHK_IX_STATS(’T’,’JESCOTT.EMPLOYEE’)
Usage note
Syntax
REORGCHK_TB_STATS ( scope , criteria )
Procedure parameters
scope
An input argument of type CHAR(1) that specifies the scope of the tables that
are to be evaluated, using one of the following values:
’T’ Table
’S’ Schema
criteria
An input argument of type VARCHAR(259). If scope has a value of ’T’, specifies
a fully qualified table name, or accepts one of the following values: ALL,
USER, or SYSTEM. If scope has a value of ’S’, specifies a schema name.
Authorization
v SELECT privilege on catalog tables.
v EXECUTE privilege on the REORGCHK_TB_STATS procedure.
Example
CALL SYSPROC.REORGCHK_TB_STATS(’T’,’JESCOTT.EMPLOYEE’)
Usage note
This SQLERRM scalar function takes a message identifier, locale and token input
and returns the short or long message of type VARCHAR(32672) in the specified
Syntax
SQLERRM ( msgid , tokens , token_delimiter , locale , shortmsg
)
Authorization
Examples
Example 1: Retrieve the English short message for SQL0551N with tokens
″AYYANG″, ″UPDATE″ and ″SYSCAT.TABLES″.
VALUES (SYSPROC.SQLERRM
(’SQL551’, ’AYYANG;UPDATE;SYSCAT.TABLES’, ’;’, ’en_US’, 1))
Example 2: Retrieve the English error message associated with SQLSTATE 42501.
VALUES (SYSPROC.SQLERRM (’42501’, ’’, ’’, ’en_US’, 1))
Explanation:
User Response:
sqlcode : -1001
sqlstate : 2E000
This SQLERRM scalar function takes an SQLCODE as the only input and returns
the short message of type VARCHAR(32672) for the specified SQLCODE in
English.
Syntax
SQLERRM ( sqlcode )
Authorization
SYSINSTALLOBJECTS
The SYSINSTALLOBJECTS procedure creates or drops the database objects that are
required for a specific tool.
Syntax
SYSINSTALLOBJECTS ( tool-name , action , tablespace-name ,
schema-name )
Procedure parameters
tool-name
An input argument of type VARCHAR(128) that specifies the name of the tool
that is to be loaded, using one of the following values:
v ’AM’ for creating activity monitor objects
v ’DB2AC’ for autonomous computing (health monitor)
v ’STMG_DBSIZE_INFO’ for storage management
v ’OPT_PROFILES’ for creating the optimization profile table
v ’POLICY’ for policy (tables and triggers)
v ’EXPLAIN’ for creating explain tables
action
An input argument of type CHAR(1) that specifies the action that is to be
taken. Valid values are:
’C’ Create objects.
’D’ Drop objects.
’V’ Verify objects.
tablespace-name
An input argument of type VARCHAR(128) that specifies the name of the table
space in which the objects are to be created. If a value is not specified, or the
value is an empty or blank string the default user space will be used if the tool
name is AM. Otherwise, the SYSTOOLSPACE table space will be used. If
SYSTOOLSPACE does not already exist, it will be created.
schema-name
Except for ’EXPLAIN’ tool-name option, SYSTOOLS is always used as the
schema regardless of the schema-name passed as the input parameter.
Example
CALL SYSPROC.SYSINSTALLOBJECTS(’AM’, ’C’, CAST (NULL AS VARCHAR(128)),
CAST (NULL AS VARCHAR(128)))
Applications that use the DB2 Version 9.1 table functions should be modified to
use the new functions or administrative views. The new table functions have the
same base names as the original functions but are suffixed with ’_Vxx’ for the
version of the product in which they were added (for example, _V95). In most
cases, the new table functions and administrative views return additional
information. The administrative views will always be based on the most current
version of the table functions, and therefore allow for more application portability.
Since the columns might vary from one release to the next (that is, some are added
and some are deleted), it is recommended that specific columns be selected from
the administrative views, or that the result set be described if a SELECT *
statement is used by an application.
Table 209. Deprecated SQL administrative routines and their replacement routines or views
for DB2 Version 9.5
DB2 Version 9.1 deprecated
function New DB2 Version 9.5 function or view
“ADMIN_GET_TAB_INFO table “ADMINTABINFO administrative view and
function - Retrieve size and state ADMIN_GET_TAB_INFO_V95 table function -
information for tables” on page 704 Retrieve size and state information for tables” on
page 199
“SNAP_GET_APPL table function – “SNAPAPPL administrative view and
Retrieve appl logical data group SNAP_GET_APPL_V95 table function - Retrieve appl
snapshot information” on page 715 logical data group snapshot information” on page
332
“SNAP_GET_APPL_INFO table “SNAPAPPL_INFO administrative view and
function – Retrieve appl_info logical SNAP_GET_APPL_INFO_V95 table function -
data group snapshot information” Retrieve appl_info logical data group snapshot
on page 721 information” on page 324
“SNAP_GET_BP table function – “SNAPBP administrative view and
Retrieve bufferpool logical group SNAP_GET_BP_V95 table function - Retrieve
snapshot information” on page 728 bufferpool logical group snapshot information” on
page 340
“SNAP_GET_DB_V91 table function “SNAPDB administrative view and
- Retrieve snapshot information SNAP_GET_DB_V95 table function - Retrieve
from the dbase logical group” on snapshot information from the dbase logical group”
page 742 on page 351
“SNAP_GET_DBM table function – “SNAPDBM administrative view and
Retrieve the dbm logical grouping SNAP_GET_DBM_V95 table function - Retrieve the
snapshot information” on page 739 dbm logical grouping snapshot information” on page
366
“SNAP_GET_DYN_SQL_V91 table “SNAPDYN_SQL administrative view and
function - Retrieve dynsql logical SNAP_GET_DYN_SQL_V95 table function - Retrieve
group snapshot information” on dynsql logical group snapshot information” on page
page 752 375
Note: (1) These functions were present in DB2 UDB for Linux, UNIX, and
Windows Version 8, but were omitted from the documentation.
Syntax
ADMIN_GET_TAB_INFO ( tabschema , tabname )
Authorization
Example
Example 1: Retrieve size and state information for the table DBUSER1.EMPLOYEE.
SELECT * FROM TABLE (SYSPROC.ADMIN_GET_TAB_INFO(’DBUSER1’, ’EMPLOYEE’))
AS T
Calculate how much space would be required if the table were moved to another
table space, where the new table space has the same page size and extent size as
the original table space:
SELECT (data_object_l_size + index_object_l_size + long_object_l_size +
lob_object_l_size + xml_object_l_size) as total_l_size
FROM TABLE( SYSPROC.ADMIN_GET_TAB_INFO( ’DBUSER1’, ’EMPLOYEE’ )) AS T
Usage notes
v If both the tabschema and tabname are specified, information is returned for that
specific table only.
v If the tabschema is specified but tabname is empty (″) or NULL, information is
returned for all tables in the given schema.
v If the tabschema is empty (″) or NULL and tabname is specified, an error is
returned. To retrieve information for a specific table, the table must be identified
by both schema and table name.
v If both tabschema and tabname are empty (″) or NULL, information is returned for
all tables.
v If tabschema or tabname do not exist, or tabname does not correspond to a table
name (type T), a materialized query table name (type S) or a hierarchy table
name (type H), an empty result set is returned.
GET_DB_CONFIG ( )
The procedure returns a single result set with two rows containing a column for
each parameter. The first column is named DBCONFIG_TYPE, as shown below.
Table 212. Information returned by the GET_DB_CONFIG procedure
Column name Data type Description
DBCONFIG_TYPE INTEGER The row with a value of 0 in this column
contains the values of the database
configuration parameters stored on disk. The
row with a value of 1 in this column
contains the current values of the database
configuration parameters stored in memory.
This procedure requires a user temporary table space that is used to create a global
temporary table named DB_CONFIG to store the result set.
Example
Using the command line processor (CLP), change the value of the logretain and the
userexit database configuration parameters. Retrieve the original (on disk) and
updated (in memory) values by calling the GET_DB_CONFIG procedure and then
querying the resulting global temporary table (DB_CONFIG).
CONNECT TO SAMPLE
CALL SYSPROC.GET_DB_CONFIG()
CONNECT RESET
2 record(s) selected.
GET_DBM_CONFIG
Note: This table function has been deprecated and replaced by the “DBMCFG
administrative view - Retrieve database manager configuration parameter
information” on page 216.
GET_DBM_CONFIG ( )
The function returns a table with two rows containing a column for each
parameter. The first column is named DBMCONFIG_TYPE, as shown below.
Table 213. Information returned by the GET_DBM_CONFIG table function
Column name Data type Description
DBMCONFIG_TYPE INTEGER The row with a value of 0 in this column
contains the values of the database manager
configuration parameters stored on disk. The
row with a value of 1 in this column
contains the current values of the database
manager configuration parameters stored in
memory.
Example
Using the command line processor (CLP), change the value of the numdb and the
diaglevel database manager configuration parameters, and then retrieve the original
(on disk) and updated (in memory) values.
UPDATE DBM CFG USING NUMDB 32 DIAGLEVEL 4
CONNECT TO SAMPLE
CONNECT RESET
2 record(s) selected.
Refer to Table 214 on page 716 for a complete list of information that can be
returned.
Syntax
SNAP_GET_APPL ( dbname )
, dbpartitionnum
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_APPL table function takes a snapshot for the currently connected
database and database partition number.
Example
Retrieve details on rows read and written for each application for all active
databases.
SELECT SUBSTR(DB_NAME,1,8) AS DB_NAME, AGENT_ID, ROWS_READ, ROWS_WRITTEN
FROM TABLE (SNAP_GET_APPL(CAST(NULL AS VARCHAR(128)),-1)) AS T
Information returned
Table 214. Information returned by the SNAP_GET_APPL table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
DB_NAME VARCHAR(128) db_name - Database name
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
UOW_LOG_SPACE_USED BIGINT uow_log_space_used - Unit of
work log space used
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
INACT_STMTHIST_SZ BIGINT stmt_history_list_size - Statement
history list size
POOL_DATA_L_READS BIGINT pool_data_l_reads - Buffer pool
data logical reads
POOL_DATA_P_READS BIGINT pool_data_p_reads - Buffer pool
data physical reads
POOL_DATA_WRITES BIGINT pool_data_writes - Buffer pool data
writes
POOL_INDEX_L_READS BIGINT pool_index_l_reads - Buffer pool
index logical reads
POOL_INDEX_P_READS BIGINT pool_index_p_reads - Buffer pool
index physical reads
POOL_INDEX_WRITES BIGINT pool_index_writes - Buffer pool
index writes
POOL_TEMP_DATA_L_READS BIGINT pool_temp_data_l_reads - Buffer
pool temporary data logical reads
Refer to Table 215 on page 723 for a complete list of information that can be
returned.
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_APPL_INFO table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_APPL_INFO table function.
Examples
4 record(s) selected.
The following shows what you obtain when you SELECT from the result of the
table function.
3 record(s) selected.
Information returned
Table 215. Information returned by the SNAP_GET_APPL_INFO table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
AGENT_ID BIGINT agent_id - Application handle
(agent ID)
The SNAP_GET_BP table function returns information about buffer pools from a
bufferpool snapshot, in particular, the bufferpool logical data group.
Refer to Table 216 on page 729 for a complete list of information that can be
returned.
Syntax
SNAP_GET_BP ( dbname )
, dbpartitionnum
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_BP table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_BP table function.
Retrieve total physical and logical reads for all bufferpools for all active databases
for the currently connected database partition.
SELECT SUBSTR(T.DB_NAME,1,10) AS DB_NAME,
SUBSTR(T.BP_NAME,1,20) AS BP_NAME,
(T.POOL_DATA_L_READS+T.POOL_INDEX_L_READS) AS TOTAL_LOGICAL_READS,
(T.POOL_DATA_P_READS+T.POOL_INDEX_P_READS) AS TOTAL_PHYSICAL_READS,
T.DBPARTITIONNUM
FROM TABLE(SNAP_GET_BP(CAST(NULL AS VARCHAR(128)), -1)) AS T
3 record(s) selected.
Information returned
Table 216. Information returned by the SNAP_GET_BP table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
BP_NAME VARCHAR(128) bp_name - Buffer pool name
DB_NAME VARCHAR(128) db_name - Database name
DB_PATH VARCHAR(1024) db_path - Database path
INPUT_DB_ALIAS VARCHAR(128) input_db_alias - Input database
alias
POOL_DATA_L_READS BIGINT pool_data_l_reads - Buffer pool
data logical reads
POOL_DATA_P_READS BIGINT pool_data_p_reads - Buffer pool
data physical reads
POOL_DATA_WRITES BIGINT pool_data_writes - Buffer pool data
writes
POOL_INDEX_L_READS BIGINT pool_index_l_reads - Buffer pool
index logical reads
POOL_INDEX_P_READS BIGINT pool_index_p_reads - Buffer pool
index physical reads
POOL_INDEX_WRITES BIGINT pool_index_writes - Buffer pool
index writes
POOL_XDA_L_READS BIGINT pool_xda_l_reads - Buffer Pool
XDA Data Logical Reads
SNAP_GET_CONTAINER
Note: This table function has been deprecated and replaced by the
“SNAPCONTAINER administrative view and SNAP_GET_CONTAINER_V91 table
function - Retrieve tablespace_container logical data group snapshot information”
on page 347
If both parameters are set to NULL, the snapshot will be taken only if a file has
not previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAP_GET_DB
Note: This table function has been deprecated and replaced by the
“SNAP_GET_DB_V91 table function - Retrieve snapshot information from the
dbase logical group” on page 742
The SNAP_GET_DB table function returns snapshot information from the database.
dbname
An input argument of type VARCHAR(255) that specifies a valid database
name in the same instance as the currently connected database when calling
this function. Specify a database name that has a directory entry type of either
″Indirect″ or ″Home″, as returned by the LIST DATABASE DIRECTORY
command. Specify the null value to take the snapshot from the currently
connected database.
dbpartitionnum
An input argument of type INTEGER that specifies a valid database partition
number. Specify -1 for the current database partition, or -2 for all active
database partitions. An active database partition is a partition where the
database is available for connection and use by applications.
If the null value is specified, -1 is set implicitly.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
The SNAP_GET_DBM table function returns the snapshot monitor DB2 database
manager (dbm) logical grouping information.
Refer to Table 219 on page 740 for a complete list of information that can be
returned.
Syntax
SNAP_GET_DBM ( )
dbpartitionnum
If dbpartitionnum is 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_DBM table function calls the snapshot from memory.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DBM table function.
Example
Retrieve the start time and current status of database partition number 2.
SELECT DB2START_TIME, DB2_STATUS FROM TABLE(SNAP_GET_DBM(2)) AS T
Information returned
Table 219. Information returned by the SNAP_GET_DBM table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
SORT_HEAP_ALLOCATED BIGINT sort_heap_allocated - Total sort
heap allocated
POST_THRESHOLD_SORTS BIGINT post_threshold_sorts - Post
threshold sorts
PIPED_SORTS_REQUESTED BIGINT piped_sorts_requested - Piped sorts
requested
PIPED_SORTS_ACCEPTED BIGINT piped_sorts_accepted - Piped sorts
accepted
REM_CONS_IN BIGINT rem_cons_in - Remote connections
to database manager
REM_CONS_IN_EXEC BIGINT rem_cons_in_exec - Remote
Connections Executing in the
Database Manager monitor element
LOCAL_CONS BIGINT local_cons - Local connections
Refer to Table 220 on page 744 for a complete list of information that is returned.
Syntax
SNAP_GET_DB_V91 ( dbname )
, dbpartitionnum
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_DB_V91 table function takes a snapshot for the currently connected
database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DB_V91 table function.
Examples
Example 1: Retrieve the status, platform, location, and connect time as an aggregate
view across all database partitions of the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME FROM TABLE(SNAP_GET_DB_V91(’’, -2)) AS T
1 record(s) selected.
Example 2: Retrieve the status, platform, location, and connect time as an aggregate
view across all database partitions for all active databases in the same instance that
contains the currently connected database.
SELECT SUBSTR(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS, SERVER_PLATFORM,
DB_LOCATION, DB_CONN_TIME
FROM TABLE(SNAP_GET_DB_V91(CAST (NULL AS VARCHAR(128)), -2)) AS T
This table function returns information equivalent to the GET SNAPSHOT FOR
DYNAMIC SQL ON database-alias CLP command.
Refer to Table 221 on page 753 for a complete list of information that can be
returned.
Syntax
SNAP_GET_DYN_SQL_V91 ( dbname )
, dbpartitionnum
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_DYN_SQL_V91 table function takes a snapshot for the currently
connected database and database partition number.
Authorization
v SYSMON authority
v EXECUTE privilege on the SNAP_GET_DYN_SQL_V91 table function.
Retrieve a list of dynamic SQL run on the currently connected database partition of
the currently connected database, ordered by the number of rows read.
SELECT PREP_TIME_WORST, NUM_COMPILATIONS, SUBSTR(STMT_TEXT, 1, 60)
AS STMT_TEXT FROM TABLE(SNAP_GET_DYN_SQL_V91(’’,-1)) as T
ORDER BY ROWS_READ
Information returned
Table 221. Information returned by the SNAP_GET_DYN_SQL_V91 table function
Description or corresponding
Column name Data type monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the
snapshot was taken.
NUM_EXECUTIONS BIGINT num_executions - Statement
executions
NUM_COMPILATIONS BIGINT num_compilations - Statement
compilations
PREP_TIME_WORST BIGINT prep_time_worst - Statement worst
preparation time
PREP_TIME_BEST BIGINT prep_time_best - Statement best
preparation time
INT_ROWS_DELETED BIGINT int_rows_deleted - Internal rows
deleted
SNAP_GET_DYN_SQL
Note: This table function has been deprecated and replaced by the
“SNAP_GET_DYN_SQL_V91 table function - Retrieve dynsql logical group
snapshot information” on page 752
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAP_GET_STO_PATHS
Note: This table function has been deprecated and replaced by the
“SNAPSTORAGE_PATHS administrative view and SNAP_GET_STORAGE_PATHS
table function - Retrieve automatic storage path information” on page 403
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
The SNAP_GET_TAB table function returns snapshot information from the table
logical data group.
dbname
An input argument of type VARCHAR(255) that specifies a valid database
name in the same instance as the currently connected database when calling
this function. Specify a database name that has a directory entry type of either
″Indirect″ or ″Home″, as returned by the LIST DATABASE DIRECTORY
command. Specify the NULL value to take the snapshot from the currently
connected database.
dbpartitionnum
An input argument of type INTEGER that specifies a valid database partition
number. Specify -1 for the current database partition, or -2 for all active
database partitions. An active database partition is a partition where the
database is available for connection and use by applications.
If the null value is specified, -1 is set implicitly.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAP_GET_TBSP
Note: This table function has been deprecated and replaced by the “SNAPTBSP
administrative view and SNAP_GET_TBSP_V91 table function - Retrieve table
space logical data group snapshot information” on page 419
The SNAP_GET_TBSP table function returns snapshot information from the table
space logical data group.
dbname
An input argument of type VARCHAR(255) that specifies a valid database
name in the same instance as the currently connected database when calling
this function. Specify a database name that has a directory entry type of either
″Indirect″ or ″Home″, as returned by the LIST DATABASE DIRECTORY
command. Specify the null value to take the snapshot from the currently
connected database.
dbpartitionnum
An input argument of type INTEGER that specifies a valid database partition
number. Specify -1 for the current database partition. If the null value is
specified, -1 is set implicitly.
If both parameters are set to NULL, the snapshot will be taken only if a file has
not previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAP_GET_TBSP_PART
Note: This table function has been deprecated and replaced by the
“SNAPTBSP_PART administrative view and SNAP_GET_TBSP_PART_V91 table
function - Retrieve tablespace_nodeinfo logical data group snapshot information”
on page 424
If both parameters are set to NULL, the snapshot will be taken only if a file has
not previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_AGENT
Note: This table function has been deprecated and replaced by the “SNAPAGENT
administrative view and SNAP_GET_AGENT table function – Retrieve agent
logical data group application snapshot information” on page 318.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_APPL
Returns general information from an application snapshot.
Note: This table function has been deprecated and replaced by the
“SNAP_GET_APPL table function – Retrieve appl logical data group snapshot
information” on page 715.
SNAPSHOT_APPL_INFO
Returns general information from an application snapshot.
Note: This table function has been deprecated and replaced by the
“SNAP_GET_APPL_INFO table function – Retrieve appl_info logical data group
snapshot information” on page 721.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_BP
Returns information from a buffer pool snapshot.
Note: This table function has been deprecated and replaced by the
“SNAP_GET_BP table function – Retrieve bufferpool logical group snapshot
information” on page 728.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_CONTAINER
Returns container configuration information from a table space snapshot.
Note: This table function has been deprecated and replaced by the
“SNAPCONTAINER administrative view and SNAP_GET_CONTAINER_V91 table
function - Retrieve tablespace_container logical data group snapshot information”
on page 347
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_DATABASE
Returns information from a database snapshot.
Note: This table function has been deprecated and replaced by the
“SNAP_GET_DB_V91 table function - Retrieve snapshot information from the
dbase logical group” on page 742
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_DBM
Returns information from a snapshot of the DB2 database manager.
Note: This table function has been deprecated and replaced by the
“SNAP_GET_DBM table function – Retrieve the dbm logical grouping snapshot
information” on page 739.
SNAPSHOT_DBM ( dbpartitionnum )
If the null value is specified, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_DYN_SQL
Returns information from a dynamic SQL snapshot. It replaces the
SQLCACHE_SNAPSHOT function, which is still available for compatibility
reasons.
Note: This table function has been deprecated and replaced by the
“SNAP_GET_DYN_SQL_V91 table function - Retrieve dynsql logical group
snapshot information” on page 752
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_FCM
Note: This table function has been deprecated and replaced by the “SNAPFCM
administrative view and SNAP_GET_FCM table function – Retrieve the fcm logical
data group snapshot information” on page 380.
SNAPSHOT_FCM ( dbpartitionnum )
SNAPSHOT_FCMNODE
Returns information from a snapshot of the fast communication manager in the
database manager.
Note: This table function has been deprecated and replaced by the
“SNAPFCM_PART administrative view and SNAP_GET_FCM_PART table function
– Retrieve the fcm_node logical data group snapshot information” on page 382.
If the null value is specified, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_FILEW
Note: This procedure has been deprecated and replaced by the
“SNAP_WRITE_FILE procedure” on page 441.
SNAPSHOT_LOCK
Returns information from a lock snapshot.
Note: This table function has been deprecated and replaced by the “SNAPLOCK
administrative view and SNAP_GET_LOCK table function – Retrieve lock logical
data group snapshot information” on page 388.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_LOCKWAIT
Returns lock waits information from an application snapshot.
Note: This table function has been deprecated and replaced by the
“SNAPLOCKWAIT administrative view and SNAP_GET_LOCKWAIT table
function – Retrieve lockwait logical data group snapshot information” on page 393.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_QUIESCERS
Note: This table function has been deprecated and replaced by the
“SNAPTBSP_QUIESCER administrative view and SNAP_GET_TBSP_QUIESCER
table function - Retrieve quiescer table space snapshot information” on page 429.
SNAPSHOT_RANGES
Note: This table function has been deprecated and replaced by the
“SNAPTBSP_RANGE administrative view and SNAP_GET_TBSP_RANGE table
function - Retrieve range snapshot information” on page 432.
SNAPSHOT_STATEMENT
Returns information about statements from an application snapshot.
Note: This table function has been deprecated and replaced by the “SNAPSTMT
administrative view and SNAP_GET_STMT table function – Retrieve statement
snapshot information” on page 398.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_SUBSECT
Returns information about subsections of access plans from an application
snapshot.
Note: This table function has been deprecated and replaced by the
“SNAPSUBSECTION administrative view and SNAP_GET_SUBSECTION table
function – Retrieve subsection logical monitor group snapshot information” on
page 406.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_SWITCHES
Returns information about the database snapshot switch state.
Note: This table function has been deprecated and replaced by the
“SNAPSWITCHES administrative view and SNAP_GET_SWITCHES table function
– Retrieve database snapshot switch state information” on page 409.
SNAPSHOT_SWITCHES ( dbpartitionnum )
SNAPSHOT_TABLE
Returns activity information from a table snapshot.
Note: This table function has been deprecated and replaced by the “SNAPTAB
administrative view and SNAP_GET_TAB_V91 table function - Retrieve table
logical data group snapshot information” on page 412
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_TBREORG
Note: This table function has been deprecated and replaced by the
“SNAPTAB_REORG administrative view and SNAP_GET_TAB_REORG table
function - Retrieve table reorganization snapshot information” on page 415.
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_TBS
Returns activity information from a table space snapshot.
Note: This table function has been deprecated and replaced by the “SNAPTBSP
administrative view and SNAP_GET_TBSP_V91 table function - Retrieve table
space logical data group snapshot information” on page 419
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SNAPSHOT_TBS_CFG
Note: This table function has been deprecated and replaced by the
“SNAPTBSP_PART administrative view and SNAP_GET_TBSP_PART_V91 table
function - Retrieve tablespace_nodeinfo logical data group snapshot information”
on page 424
If both parameters are set to NULL, the snapshot will be taken only if a file has not
previously been created by the SNAPSHOT_FILEW stored procedure for the
corresponding snapshot API request type.
SQLCACHE_SNAPSHOT
Note: This table function has been deprecated and replaced by the
“SNAP_GET_DYN_SQL_V91 table function - Retrieve dynsql logical group
snapshot information” on page 752
SQLCACHE_SNAPSHOT ( )
The function does not take any arguments. It returns a table, as shown below.
Table 248. Information returned by SQLCACHE_SNAPSHOT table function
Description or
corresponding monitor
Column name Data type element
NUM_EXECUTIONS INTEGER num_executions - Statement
executions
NUM_COMPILATIONS INTEGER num_compilations -
Statement compilations
PREP_TIME_WORST INTEGER prep_time_worst - Statement
worst preparation time
PREP_TIME_BEST INTEGER prep_time_best - Statement
best preparation time
INT_ROWS_DELETED INTEGER int_rows_deleted - Internal
rows deleted
SYSINSTALLROUTINES
Note: This procedure has been deprecated. The procedure was used to create new
procedures and functions in DB2 UDB for Linux, UNIX, and Windows Version 8.
SYSINSTALLROUTINES ( )
Note: The DB2 Information Center topics are updated more frequently than either
the PDF or the hard-copy books. To get the most current information, install the
documentation updates as they become available, or refer to the DB2 Information
Center at ibm.com®.
You can access additional DB2 technical information such as technotes, white
papers, and IBM Redbooks® publications online at ibm.com. Access the DB2
Information Management software library site at http://www.ibm.com/software/
data/sw-library/.
Documentation feedback
We value your feedback on the DB2 documentation. If you have suggestions for
how to improve the DB2 documentation, send an email to [email protected].
The DB2 documentation team reads all of your feedback, but cannot respond to
you directly. Provide specific examples wherever possible so that we can better
understand your concerns. If you are providing feedback on a specific topic or
help file, include the topic title and URL.
Do not use this email address to contact DB2 Customer Support. If you have a DB2
technical issue that the documentation does not resolve, contact your local IBM
service center for assistance.
Although the tables identify books available in print, the books might not be
available in your country or region.
Note: The DB2 Information Center is updated more frequently than either the PDF
or the hard-copy books.
Table 249. DB2 technical information
Name Form Number Available in print
Administrative API Reference SC23-5842-01 Yes
Administrative Routines and SC23-5843-01 No
Views
Call Level Interface Guide and SC23-5844-01 Yes
Reference, Volume 1
Call Level Interface Guide and SC23-5845-01 Yes
Reference, Volume 2
Command Reference SC23-5846-01 Yes
Data Movement Utilities Guide SC23-5847-01 Yes
and Reference
Data Recovery and High SC23-5848-01 Yes
Availability Guide and Reference
Data Servers, Databases, and SC23-5849-01 Yes
Database Objects Guide
Database Security Guide SC23-5850-01 Yes
Developing ADO.NET and OLE SC23-5851-01 Yes
DB Applications
Developing Embedded SQL SC23-5852-01 Yes
Applications
Developing Java Applications SC23-5853-01 Yes
Developing Perl and PHP SC23-5854-01 No
Applications
Developing User-defined Routines SC23-5855-01 Yes
(SQL and External)
Getting Started with Database GC23-5856-01 Yes
Application Development
Getting Started with DB2 GC23-5857-01 Yes
installation and administration on
Linux and Windows
Internationalization Guide SC23-5858-01 Yes
Message Reference, Volume 1 GI11-7855-00 No
Message Reference, Volume 2 GI11-7856-00 No
Migration Guide GC23-5859-01 Yes
Net Search Extender SC23-8509-01 Yes
Administration and User’s Guide
Partitioning and Clustering Guide SC23-5860-01 Yes
Query Patroller Administration SC23-8507-00 Yes
and User’s Guide
Quick Beginnings for IBM Data GC23-5863-01 No
Server Clients
Printed versions of many of the DB2 books available on the DB2 PDF
Documentation DVD can be ordered for a fee from IBM. Depending on where you
are placing your order from, you may be able to order books online, from the IBM
Publications Center. If online ordering is not available in your country or region,
you can always order printed DB2 books from your local IBM representative. Note
that not all books on the DB2 PDF Documentation DVD are available in print.
Note: The most up-to-date and complete DB2 documentation is maintained in the
DB2 Information Center at http://publib.boulder.ibm.com/infocenter/db2luw/
v9r5.
To invoke SQL state help, open the command line processor and enter:
? sqlstate or ? class code
where sqlstate represents a valid five-digit SQL state and class code represents the
first two digits of the SQL state.
For example, ? 08003 displays help for the 08003 SQL state, and ? 08 displays help
for the 08 class code.
For DB2 Version 9 topics, the DB2 Information Center URL is http://
publib.boulder.ibm.com/infocenter/db2luw/v9/
For DB2 Version 8 topics, go to the Version 8 Information Center URL at:
http://publib.boulder.ibm.com/infocenter/db2luw/v8/
Note: Adding a language does not guarantee that the computer has the
fonts required to display the topics in the preferred language.
– To move a language to the top of the list, select the language and click the
Move Up button until the language is first in the list of languages.
3. Clear the browser cache and then refresh the page to display the DB2
Information Center in your preferred language.
v To display topics in your preferred language in a Firefox or Mozilla browser:
1. Select the button in the Languages section of the Tools —> Options —>
Advanced dialog. The Languages panel is displayed in the Preferences
window.
2. Ensure your preferred language is specified as the first entry in the list of
languages.
– To add a new language to the list, click the Add... button to select a
language from the Add Languages window.
– To move a language to the top of the list, select the language and click the
Move Up button until the language is first in the list of languages.
3. Clear the browser cache and then refresh the page to display the DB2
Information Center in your preferred language.
On some browser and operating system combinations, you might have to also
change the regional settings of your operating system to the locale and language of
your choice.
Note: The help_end batch file contains the commands required to safely
terminate the processes that were started with the help_start batch file. Do
not use Ctrl-C or any other method to terminate help_start.bat.
v On Linux, navigate to the installation directory’s doc/bin directory, and run
the help_end script:
help_end
The updated DB2 Information Center displays the new and updated topics.
DB2 tutorials
The DB2 tutorials help you learn about various aspects of DB2 products. Lessons
provide step-by-step instructions.
You can view the XHTML version of the tutorial from the Information Center at
http://publib.boulder.ibm.com/infocenter/db2help/.
Some lessons use sample data or code. See the tutorial for a description of any
prerequisites for its specific tasks.
Personal use: You may reproduce these Publications for your personal, non
commercial use provided that all proprietary notices are preserved. You may not
distribute, display or make derivative work of these Publications, or any portion
thereof, without the express consent of IBM.
Commercial use: You may reproduce, distribute and display these Publications
solely within your enterprise provided that all proprietary notices are preserved.
You may not make derivative works of these Publications, or reproduce, distribute
or display these Publications or any portion thereof outside your enterprise,
without the express consent of IBM.
You may not download, export or re-export this information except in full
compliance with all applicable laws and regulations, including all United States
export laws and regulations.
IBM may not offer the products, services, or features discussed in this document in
other countries. Consult your local IBM representative for information on the
products and services currently available in your area. Any reference to an IBM
product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product,
program, or service that does not infringe any IBM intellectual property right may
be used instead. However, it is the user’s responsibility to evaluate and verify the
operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter
described in this document. The furnishing of this document does not give you
any license to these patents. You can send license inquiries, in writing, to:
For license inquiries regarding double-byte (DBCS) information, contact the IBM
Intellectual Property Department in your country/region or send inquiries, in
writing, to:
The following paragraph does not apply to the United Kingdom or any other
country/region where such provisions are inconsistent with local law:
INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS
PUBLICATION “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS
FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or
implied warranties in certain transactions; therefore, this statement may not apply
to you.
This document may provide links or references to non-IBM Web sites and
resources. IBM makes no representations, warranties, or other commitments
whatsoever about any non-IBM Web sites or third-party resources that may be
referenced, accessible from, or linked from this document. A link to a non-IBM
Web site does not mean that IBM endorses the content or use of such Web site or
IBM may use or distribute any of the information you supply in any way it
believes appropriate without incurring any obligation to you.
Licensees of this program who wish to have information about it for the purpose
of enabling: (i) the exchange of information between independently created
programs and other programs (including this one) and (ii) the mutual use of the
information that has been exchanged, should contact:
The licensed program described in this document and all licensed material
available for it are provided by IBM under terms of the IBM Customer Agreement,
IBM International Program License Agreement, or any equivalent agreement
between us.
All statements regarding IBM’s future direction or intent are subject to change or
withdrawal without notice, and represent goals and objectives only.
This information may contain examples of data and reports used in daily business
operations. To illustrate them as completely as possible, the examples include the
names of individuals, companies, brands, and products. All of these names are
fictitious, and any similarity to the names and addresses used by an actual
business enterprise is entirely coincidental.
COPYRIGHT LICENSE:
Each copy or any portion of these sample programs or any derivative work must
include a copyright notice as follows:
© (your company name) (year). Portions of this code are derived from IBM Corp.
Sample Programs. © Copyright IBM Corp. _enter the year or years_. All rights
reserved.
Trademarks
pureXML OS/390
DB2 Connect DB2 Universal Database
1-2-3 MQSeries
Redbooks PowerPC
IBM DB2
AIX Lotus
DRDA OS/400
DYNIX ibm.com
Index 823
functions (continued) functions (continued)
table functions (continued) table functions (continued)
SNAP_GET_AGENT_MEMORY_POOL 321, 445 versus administrative views 5
SNAP_GET_APPL 715 WLM_GET_ACTIVITY_DETAILS 613
SNAP_GET_APPL_INFO 721 WLM_GET_QUEUE_STATS 619
SNAP_GET_APPL_INFO_V95 324, 449 WLM_GET_SERVICE_CLASS_
SNAP_GET_APPL_V95 332, 456 WORKLOAD_OCCURRENCESWLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES 627
SNAP_GET_BP 728 WLM_GET_SERVICE_CLASS_AGENTS 623
SNAP_GET_BP_PART 344, 468 WLM_GET_SERVICE_SUBCLASS_STATS 631
SNAP_GET_BP_V95 340, 464 WLM_GET_SERVICE_SUPERCLASS_STATS 636
SNAP_GET_CONTAINER (deprecated) 731 WLM_GET_WORK_ACTION_SET_STATS 638
SNAP_GET_CONTAINER_V91 347, 471 WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIESWLM_GET_WORKLOAD_
SNAP_GET_DB (deprecated) 732 OCCURRENCE_ACTIVITIES 640
SNAP_GET_DB_MEMORY_POOL 362, 486 WLM_GET_WORKLOAD_STATS 644
SNAP_GET_DB_V91 742
SNAP_GET_DB_V95 351, 475
SNAP_GET_DBM 739
SNAP_GET_DBM_MEMORY_POOL 370, 494
G
GENERATE_DISTFILE procedure 577
SNAP_GET_DBM_V95 366, 490
GET STMM TUNING DBPARTITIONNUM command
SNAP_GET_DETAIL_LOG_V91 372, 496
using ADMIN_CMD 71
SNAP_GET_DYN_SQL (deprecated) 755
GET_DB_CONFIG table function 713
SNAP_GET_DYN_SQL_V91 752
GET_DBM_CONFIG table function 714
SNAP_GET_DYN_SQL_V95 375, 499
GET_DBSIZE_INFO procedure 675
SNAP_GET_FCM 380, 504
GET_ROUTINE_OPTS scalar function 571
SNAP_GET_FCM_PART 382, 506
GET_ROUTINE_SAR procedure 571
SNAP_GET_HADR 384, 508
GET_SWRD_SETTINGS procedure 578
SNAP_GET_LOCK 388, 512
groups
SNAP_GET_LOCKWAIT 393, 517
retrieving group membership 289
SNAP_GET_STMT 398, 522
SNAP_GET_STO_PATHS (deprecated) 757
SNAP_GET_STORAGE_PATHS 403, 527
SNAP_GET_SUBSECTION 406, 530 H
SNAP_GET_SWITCHES 409, 533 health alerts
SNAP_GET_TAB (deprecated) 758 alert action configuration 250
SNAP_GET_TAB_REORG 415, 539 alert configuration 253
SNAP_GET_TAB_V91 412, 536 health indicators
SNAP_GET_TBSP (deprecated) 759 retrieve health indicator definition 256
SNAP_GET_TBSP_PART (deprecated) 762 HEALTH_CONT_HI table function 228
SNAP_GET_TBSP_PART_V91 424, 548 HEALTH_CONT_HI_HIS table function 230
SNAP_GET_TBSP_QUIESCER 429, 553 HEALTH_CONT_INFO table function 232
SNAP_GET_TBSP_RANGE 432, 556 HEALTH_DB_HI table function 233
SNAP_GET_TBSP_V91 419, 543 HEALTH_DB_HI_HIS table function 237
SNAP_GET_UTIL 435, 559 HEALTH_DB_HIC table function 240
SNAP_GET_UTIL_PROGRESS 439, 563 HEALTH_DB_HIC_HIS table function 242
SNAPSHOT_AGENT (deprecated) 764 HEALTH_DB_INFO table function 244
SNAPSHOT_APPL (deprecated) 765 HEALTH_DBM_HI table function 246
SNAPSHOT_APPL_INFO (deprecated) 770 HEALTH_DBM_HI_HIS table function 247
SNAPSHOT_BP (deprecated) 772 HEALTH_DBM_INFO table function 249
SNAPSHOT_CONTAINER (deprecated) 774 HEALTH_GET_ALERT_ACTION_CFG table function 250
SNAPSHOT_DATABASE (deprecated) 775 HEALTH_GET_ALERT_CFG table function 253
SNAPSHOT_DBM (deprecated) 781 HEALTH_GET_IND_DEFINITION table function 256
SNAPSHOT_DYN_SQL (deprecated) 783 HEALTH_HI_REC procedure 258
SNAPSHOT_FCM (deprecated) 784 HEALTH_TBS_HI table function 260
SNAPSHOT_FCMNODE (deprecated) 785 HEALTH_TBS_HI_HIS table function 262
SNAPSHOT_LOCK (deprecated) 787 HEALTH_TBS_INFO table function 266
SNAPSHOT_LOCKWAIT (deprecated) 788 help
SNAPSHOT_QUIESCERS (deprecated) 789 configuring language 811
SNAPSHOT_RANGES (deprecated) 790 SQL statements 810
SNAPSHOT_STATEMENT (deprecated) 791 history file
SNAPSHOT_SUBSECT (deprecated) 793 retrieving information 661
SNAPSHOT_SWITCHES (deprecated) 795
SNAPSHOT_TABLE (deprecated) 796
SNAPSHOT_TBREORG (deprecated) 797
SNAPSHOT_TBS (deprecated) 799
I
IMPORT command
SNAPSHOT_TBS_CFG (deprecated) 801
using ADMIN_CMD 72
SQLCACHE_SNAPSHOT (deprecated) 803
INITIALIZE TAPE command
supported 7
using ADMIN_CMD 97
Q
P QUERY_PREP_COST administrative view 317
PD_GET_DIAG_HIST table function QUIESCE DATABASE command
description 678 using ADMIN_CMD 136
PD_GET_LOG_MSGS table function QUIESCE TABLESPACES FOR TABLE command
description 685 using ADMIN_CMD 138
PDLOGMSGS_LAST24HOURS administrative view
description 685
privileges
information about granted
R
REBIND_ROUTINE_PACKAGE procedure 573
PRIVILEGES administrative view 294
REDISTRIBUTE DATABASE PARTITION GROUP command
PRIVILEGES administrative view 294
using ADMIN_CMD 140
problem determination
redistributing data
information available 814
procedures 575, 577, 578, 580, 582
notification log messages 685
REG_VARIABLES administrative view 219
tutorials 814
registry variables
procedures
retrieving settings in use 219
ADMIN_CMD
description 33
Index 825
REORG INDEXES/TABLE command SNAP_GET_UTIL table function 435, 559
using ADMIN_CMD 148 SNAP_GET_UTIL_PROGRESS table function 439, 563
REORGCHK_IX_STATS procedure 692 SNAP_WRITE_FILE procedure 441, 565
REORGCHK_TB_STATS procedure 694 SNAPAGENT administrative view 318, 442
RESET ALERT CONFIGURATION command SNAPAGENT_MEMORY_POOL administrative view 321, 445
using ADMIN_CMD 157 SNAPAPPL administrative view 332, 456
RESET DATABASE CONFIGURATION command SNAPAPPL_INFO administrative view 324, 449
using ADMIN_CMD 158 SNAPBP administrative view 340, 464
RESET DATABASE MANAGER CONFIGURATION command SNAPBP_PART administrative view 344, 468
using ADMIN_CMD 160 SNAPCONTAINER administrative view 347, 471
REWIND TAPE command SNAPDB administrative view 351, 475
using ADMIN_CMD 161 SNAPDB_MEMORY_POOL administrative view 362, 486
routines SNAPDBM administrative view 366, 490
SQL administrative 701 SNAPDBM_MEMORY_POOL administrative view 370, 494
supported 7 SNAPDETAILLOG administrative view 372, 496
RUNSTATS command SNAPDYN_SQL administrative view 375, 499
using ADMIN_CMD 162 SNAPFCM administrative view 380, 504
SNAPFCM_PART administrative view 382, 506
SNAPHADR administrative view 384, 508
S SNAPLOCK administrative view 388, 512
SNAPLOCKWAIT administrative view 393, 517
scalar functions
SNAPSHOT_AGENT deprecated table function 764
SQLERRM 695
SNAPSHOT_APPL deprecated table function 765
schemas
SNAPSHOT_APPL_INFO deprecated table function 770
copying schemas and objects 648
SNAPSHOT_BP deprecated table function 772
dropping objects 652
SNAPSHOT_CONTAINER deprecated table function 774
SET TAPE POSITION command
SNAPSHOT_DATABASE deprecated table function 775
using ADMIN_CMD 173
SNAPSHOT_DBM deprecated table function 781
SET_ROUTINE_OPTS procedure 574
SNAPSHOT_DYN_SQL deprecated table function 783
SET_SWRD_SETTINGS procedure 580
SNAPSHOT_FCM deprecated table function 784
SNAP_GET_AGENT table function 318, 442
SNAPSHOT_FCMNODE deprecated table function 785
SNAP_GET_AGENT_MEMORY_POOL table function 321,
SNAPSHOT_FILEW deprecated procedure 786
445
SNAPSHOT_LOCK deprecated table function 787
SNAP_GET_APPL_INFO table function 721
SNAPSHOT_LOCKWAIT deprecated table function 788
SNAP_GET_APPL_INFO_V95 table function 324, 449
SNAPSHOT_QUIESCERS deprecated table function 789
SNAP_GET_APPL_V95 table function 332, 456
SNAPSHOT_RANGES deprecated table function 790
SNAP_GET_BP_PART table function 344, 468
SNAPSHOT_STATEMENT deprecated table function 791
SNAP_GET_BP_V95 table function 340, 464
SNAPSHOT_SUBSECT deprecated table function 793
SNAP_GET_CONTAINER deprecated table function 731
SNAPSHOT_SWITCHES deprecated table function 795
SNAP_GET_CONTAINER_V91 table function 347, 471
SNAPSHOT_TABLE deprecated table function 796
SNAP_GET_DB deprecated table function 732
SNAPSHOT_TBREORG deprecated table function 797
SNAP_GET_DB_MEMORY_POOL table function 362, 486
SNAPSHOT_TBS deprecated table function 799
SNAP_GET_DB_V95 table function 351, 475
SNAPSHOT_TBS_CFG deprecated table function 801
SNAP_GET_DBM_MEMORY_POOL table function 370, 494
SNAPSTMT administrative view 398, 522
SNAP_GET_DBM_V95 table function 366, 490
SNAPSTORAGE_PATHS administrative view 403, 527
SNAP_GET_DETAIL_LOG_V91 table function 372, 496
SNAPSUBSECTION administrative view 406, 530
SNAP_GET_DYN_SQL deprecated table function 755
SNAPSWITCHES administrative view 409, 533
SNAP_GET_DYN_SQL_V91 table function 752
SNAPTAB administrative view 412, 536
SNAP_GET_DYN_SQL_V95 table function 375, 499
SNAPTAB_REORG administrative view 415, 539
SNAP_GET_FCM table function 380, 504
SNAPTBSP administrative view 419, 543
SNAP_GET_FCM_PART table function 382, 506
SNAPTBSP_QUIESCER administrative view 429, 553
SNAP_GET_HADR table function 384, 508
SNAPTBSP_RANGE administrative view 432, 556
SNAP_GET_LOCK table function 388, 512
SNAPTBSPPART administrative view 424, 548
SNAP_GET_LOCKWAIT table function 393, 517
SNAPUTIL administrative view 435, 559
SNAP_GET_STMT table function 398, 522
SNAPUTIL_PROGRESS administrative view 439, 563
SNAP_GET_STO_PATHS deprecated table function 757
split mirror
SNAP_GET_STORAGE_PATHS table function 403, 527
retrieving database paths 665
SNAP_GET_SUBSECTION table function 406, 530
SQL administrative routines 595
SNAP_GET_SWITCHES table function 409, 533
deprecated routines 701
SNAP_GET_TAB deprecated table function 758
SQL statements
SNAP_GET_TAB_REORG table function 415, 539
displaying help 810
SNAP_GET_TAB_V91 table function 412, 536
SQLCACHE_SNAPSHOT deprecated table function 803
SNAP_GET_TBSP deprecated table function 759
SQLERRM scalar function 695
SNAP_GET_TBSP_PART deprecated table function 762
STEPWISE_REDISTRIBUTE_DBPG procedure 582
SNAP_GET_TBSP_PART_V91 table function 424, 548
storage management tool
SNAP_GET_TBSP_QUIESCER table function 429, 553
stored procedures 584, 585, 586
SNAP_GET_TBSP_RANGE table function 432, 556
SNAP_GET_TBSP_V91 table function 419, 543
T
table functions U
admin_get_dbp_mem_usage 191 UNQUIESCE DATABASE command
ADMIN_GET_MSGS 193 using ADMIN_CMD 174
ADMIN_GET_TAB_INFO_V95 199 UPDATE ALERT CONFIGURATION command
AUDIT_ARCHIVE 206 using ADMIN_CMD 175
AUTH_LIST_GROUPS_FOR_AUTHID 289 UPDATE CONTACT command
deprecated functionality 701 using ADMIN_CMD 180
ADMIN_GET_TAB_INFO 704 UPDATE CONTACTGROUP command
SNAP_GET_APPL_INFO 721 using ADMIN_CMD 181
SNAP_GET_BP 728 UPDATE DATABASE CONFIGURATION command
SNAP_GET_DB_V91 742 using ADMIN_CMD 183
SNAP_GET_DBM 739 UPDATE DATABASE MANAGER CONFIGURATION
SNAP_GET_DYN_SQL_V91 752 command
HEALTH_GET_ALERT_ACTION_CFG 250 using ADMIN_CMD 185
HEALTH_GET_ALERT_CFG 253 UPDATE HEALTH NOTIFICATION CONTACT LIST
HEALTH_GET_IND_DEFINITION 256 command
PD_GET_DIAG_HIST 678 using ADMIN_CMD 187
PD_GET_LOG_MSGS 685 UPDATE HISTORY command
SNAP_GET_AGENT 318, 442 using ADMIN_CMD 188
SNAP_GET_AGENT_MEMORY_POOL 321, 445 UPDATE STMM TUNING DBPARTITIONNUM Command
SNAP_GET_APPL_INFO_V95 324, 449 using ADMIN_CMD 190
SNAP_GET_APPL_V95 332, 456 updates
SNAP_GET_BP_PART 344, 468 DB2 Information Center 812
SNAP_GET_BP_V95 340, 464
SNAP_GET_CONTAINER_V91 347, 471
SNAP_GET_DB_MEMORY_POOL 362, 486
SNAP_GET_DB_V95 351, 475
V
views
SNAP_GET_DBM_MEMORY_POOL 370, 494
administrative views
SNAP_GET_DBM_V95 366, 490
ADMINTABCOMPRESSINFO 194
SNAP_GET_DETAIL_LOG_V91 372, 496
ADMINTABINFO 199
SNAP_GET_DYN_SQL_V95 375, 499
APPL_PERFORMANCE 295
SNAP_GET_FCM 380, 504
APPLICATIONS 296
SNAP_GET_FCM_PART 382, 506
AUTHORIZATIONIDS 292
SNAP_GET_HADR 384, 508
BP_HITRATIO 300
SNAP_GET_LOCK 388, 512
BP_READ_IO 302
SNAP_GET_LOCKWAIT 393, 517
BP_WRITE_IO 304
SNAP_GET_STMT 398, 522
CONTACTGROUPS 659
SNAP_GET_STORAGE_PATHS 403, 527
CONTACTS 660
SNAP_GET_SUBSECTION 406, 530
CONTAINER_UTILIZATION 305
SNAP_GET_SWITCHES 409, 533
DB_HISTORY 661
SNAP_GET_TAB_REORG 415, 539
DBCFG 214
SNAP_GET_TAB_V91 412, 536
DBMCFG 216
SNAP_GET_TBSP_PART_V91 424, 548
DBPATHS 665
SNAP_GET_TBSP_QUIESCER 429, 553
ENV_FEATURE_INFO 223
SNAP_GET_TBSP_RANGE 432, 556
Index 827
views (continued) WLM_GET_SERVICE_SUBCLASS_STATS table function
administrative views (continued) description 631
ENV_INST_INFO 220 WLM_GET_SERVICE_SUPERCLASS_STATS table function
ENV_PROD_INFO 221 description 636
ENV_SYS_INFO 224 WLM_GET_WORK_ACTION_SET_STATS table function
ENV_SYS_RESOURCES 225 description 638
LOCKS_HELD 307 WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES table
LOCKWAIT 310 function
LOG_UTILIZATION 314 description 640
LONG_RUNNING_SQL 315 WLM_GET_WORKLOAD_STATS table function
NOTIFICATIONLIST 677 description 644
OBJECTOWNERS 293 WLM_SET_CLIENT_INFO procedure 646
PDLOGMSGS_LAST24HOURS 685
PRIVILEGES 294
QUERY_PREP_COST 317
REG_VARIABLES 219
SNAPAGENT 318, 442
SNAPAGENT_MEMORY_POOL 321, 445
SNAPAPPL 332, 456
SNAPAPPL_INFO 324, 449
SNAPBP 340, 464
SNAPBP_PART 344, 468
SNAPCONTAINER 347, 471
SNAPDB 351, 475
SNAPDB_MEMORY_POOL 362, 486
SNAPDBM 366, 490
SNAPDBM_MEMORY_POOL 370, 494
SNAPDETAILLOG 372, 496
SNAPDYN_SQL 375, 499
SNAPFCM 380, 504
SNAPFCM_PART 382, 506
SNAPHADR 384, 508
SNAPLOCK 388, 512
SNAPLOCKWAIT 393, 517
SNAPSTMT 398, 522
SNAPSTORAGE_PATHS 403, 527
SNAPSUBSECTION 406, 530
SNAPSWITCHES 409, 533
SNAPTAB 412, 536
SNAPTAB_REORG 415, 539
SNAPTBSP 419, 543
SNAPTBSP_QUIESCER 429, 553
SNAPTBSP_RANGE 432, 556
SNAPTBSPPART 424, 548
SNAPUTIL 435, 559
SNAPUTIL_PROGRESS 439, 563
TBSP_UTILIZATION 566
TOP_DYNAMIC_SQL 570
Visual Explain
tutorial 813
W
WLM_CANCEL_ACTIVITY procedure 609
WLM_CAPTURE_ACTIVITY_IN_PROGRESS procedure 610
WLM_COLLECT_STATS procedure
description 612
WLM_GET_ACTIVITY_DETAILS table function
description 613
WLM_GET_QUEUE_STATS table function
description 619
WLM_GET_SERVICE_CLASS_AGENTS table function
description 623
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES
table function
description 627
Printed in USA
SC23-5843-01
Spine information:
DB2 Version 9.5 for Linux, UNIX, and Windows Administrative Routines and Views