db2 Built-In Routines and Views 115
db2 Built-In Routines and Views 115
IBM
Notices
This information was developed for products and services offered in the US. This material might be
available from IBM in other languages. However, you may be required to own a copy of the product or
product version in that language in order to access it.
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 grant you any license to these patents. You can send
license inquiries, in writing, to:
For license inquiries regarding double-byte character set (DBCS) information, contact the IBM Intellectual
Property Department in your country or send inquiries, in writing, to:
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_.
Trademarks
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business
Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be
trademarks of IBM or other companies. A current list of IBM trademarks is available on the web at
"Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the
United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or
its affiliates.
Applicability
These terms and conditions are in addition to any terms of use for the IBM website.
ii Notices
Personal use
You may reproduce these publications for your personal, noncommercial 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.
Rights
Except as expressly granted in this permission, no other permissions, licenses or rights are granted, either
express or implied, to the publications or any information, data, software or other intellectual property
contained therein.
IBM reserves the right to withdraw the permissions granted herein whenever, in its discretion, the use of
the publications is detrimental to its interest or, as determined by IBM, the above instructions are not
being properly followed.
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 MAKES NO GUARANTEE ABOUT THE CONTENT OF THESE PUBLICATIONS. THE PUBLICATIONS ARE
PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY, NON-
INFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
Notices iii
iv IBM Db2 V11.5: Built-In Routines and Views
Contents
Notices...................................................................................................................i
Trademarks...................................................................................................................................................ii
Terms and conditions for product documentation......................................................................................ii
Figures................................................................................................................. xi
Tables................................................................................................................ xiii
v
Chapter 4. Snapshot routines and views.............................................................973
QUERY_PREP_COST - statement prepare time...................................................................................... 973
SNAP_GET_DYN_SQL - dynsql snapshot................................................................................................ 974
SNAP_GET_SUBSECTION - subsection logical monitor group snapshot...............................................980
SNAP_GET_SWITCHES - database snapshot switch state information.................................................984
SNAP_GET_TAB_REORG - table reorganization snapshot..................................................................... 987
SNAP_GET_UTIL_PROGRESS - progress snapshot................................................................................ 994
SNAPDYN_SQL - dynsql snapshot.......................................................................................................... 997
SNAPSUBSECTION - subsection logical monitor group snapshot.......................................................1003
SNAPSWITCHES- database snapshot switch state information......................................................... 1007
SNAPTAB_REORG - table reorganization snapshot............................................................................. 1010
SNAPUTIL_PROGRESS - progress snapshot........................................................................................ 1017
TOP_DYNAMIC_SQL - top dynamic SQL statements........................................................................... 1020
vi
WLM_ALTER_MEMBER_SUBSET - alter a member subset object...................................................... 1086
WLM_CREATE_MEMBER_SUBSET - create a member subset object................................................. 1089
WLM_DROP_MEMBER_SUBSET - drop a member subset object........................................................ 1092
WLM_GET_CONN_ENV - get settings for activity data collection for a connection............................ 1092
WLM_GET_QUEUE_STATS - return threshold queue statistics........................................................... 1094
WLM_GET_SERVICE_CLASS_AGENTS table function - list agents running in a service class............1095
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES table function - list workload
occurrences...................................................................................................................................... 1095
WLM_GET_SERVICE_SUBCLASS_STATS - return statistics of service subclasses.............................1098
WLM_GET_SERVICE_SUPERCLASS_STATS - return statistics of service superclasses..................... 1099
WLM_GET_WORK_ACTION_SET_STATS - return work action set statistics...................................... 1099
WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES table function - return a list of activities........ 1099
WLM_GET_WORKLOAD_STATS - return workload statistics............................................................... 1100
WLM_SET_CLIENT_INFO - set client information................................................................................1100
WLM_SET_CONN_ENV - enable collection of activity data and measurement of section actuals.....1102
WLM_SET_SESSION_PRIORITY procedure - Set the priority of a given session................................1105
vii
ENV_GET_SYS_RESOURCES - return system information...................................................................1217
GET_DB_CONFIG...................................................................................................................................1221
GET_DBM_CONFIG............................................................................................................................... 1222
Health snapshot routines...................................................................................................................... 1223
HEALTH_CONT_HI - container health indicators........................................................................... 1223
HEALTH_CONT_HI_HIS - container health indicator history.........................................................1225
HEALTH_CONT_INFO - container information............................................................................... 1227
HEALTH_DB_HI - database health indicators................................................................................ 1229
HEALTH_DB_HI_HIS - database health indicator history..............................................................1232
HEALTH_DB_HIC - collection health indicator............................................................................... 1235
HEALTH_DB_HIC_HIS - collection health indicator history...........................................................1237
HEALTH_DB_INFO - database information.................................................................................... 1240
HEALTH_DBM_HI - database manager health indicators..............................................................1242
HEALTH_DBM_HI_HIS - database manager health indicator history........................................... 1243
HEALTH_DBM_INFO - database manager information..................................................................1245
HEALTH_GET_ALERT_ACTION_CFG - health alert action configuration settings.........................1247
HEALTH_GET_ALERT_CFG - health alert configuration settings................................................... 1250
HEALTH_GET_IND_DEFINITION - health indicator definitions.....................................................1253
HEALTH_HI_REC - recommendations............................................................................................ 1255
HEALTH_TBS_HI - table space health indicators........................................................................... 1257
HEALTH_TBS_HI_HIS - table space health indicator history........................................................ 1259
HEALTH_TBS_INFO - table space information...............................................................................1263
LOCKS_HELD - locks held..................................................................................................................... 1265
LOCKWAITS - current lockwaits........................................................................................................... 1268
LOG_UTILIZATION - log utilization.......................................................................................................1272
LONG_RUNNING_SQL - longest running SQL statement ....................................................................1273
REG_VARIABLES - database registry settings in use........................................................................... 1276
REG_LIST_VARIABLES table function - return registry settings......................................................... 1277
SNAP_GET_AGENT................................................................................................................................ 1279
SNAP_GET_AGENT_MEMORY_POOL................................................................................................... 1282
SNAP_GET_APPL_INFO........................................................................................................................ 1287
SNAP_GET_APPL_INFO_V95................................................................................................................ 1295
SNAP_GET_APPL................................................................................................................................... 1301
SNAP_GET_APPL_V95...........................................................................................................................1309
SNAP_GET_BP....................................................................................................................................... 1316
SNAP_GET_BP_PART.............................................................................................................................1321
SNAP_GET_BP_V95............................................................................................................................... 1325
SNAP_GET_CONTAINER........................................................................................................................1329
SNAP_GET_CONTAINER_V91............................................................................................................... 1333
SNAP_GET_DB....................................................................................................................................... 1335
SNAP_GET_DB_MEMORY_POOL...........................................................................................................1348
SNAP_GET_DB_V97...............................................................................................................................1353
SNAP_GET_DBM.................................................................................................................................... 1363
SNAP_GET_DBM_MEMORY_POOL....................................................................................................... 1368
SNAP_GET_DBM_V95............................................................................................................................1371
SNAP_GET_DETAILLOG.........................................................................................................................1374
SNAP_GET_DETAILLOG_V91................................................................................................................ 1377
SNAP_GET_DYN_SQL_V95....................................................................................................................1379
SNAP_GET_FCM.....................................................................................................................................1383
SNAP_GET_FCM_PART..........................................................................................................................1386
SNAP_GET_HADR.................................................................................................................................. 1389
SNAP_GET_LOCK...................................................................................................................................1393
SNAP_GET_LOCKWAIT..........................................................................................................................1398
SNAP_GET_TBSP_RANGE......................................................................................................................1404
SNAP_GET_STMT...................................................................................................................................1408
SNAP_GET_STO_PATHS........................................................................................................................ 1414
SNAP_GET_STORAGE_PATHS_V97...................................................................................................... 1415
SNAP_GET_TAB..................................................................................................................................... 1419
viii
SNAP_GET_TAB_V91............................................................................................................................. 1422
SNAP_GET_TBSP................................................................................................................................... 1424
SNAP_GET_TBSP_PART......................................................................................................................... 1430
SNAP_GET_TBSP_PART_V97................................................................................................................ 1435
SNAP_GET_TBSP_V91........................................................................................................................... 1439
SNAP_GET_TBSP_QUIESCER................................................................................................................ 1443
SNAP_GET_UTIL.................................................................................................................................... 1447
SNAP_WRITE_FILE................................................................................................................................1451
SNAPAGENT...........................................................................................................................................1452
SNAPAGENT_MEMORY_POOL..............................................................................................................1456
SNAPAPPL_INFO...................................................................................................................................1460
SNAPAPPL..............................................................................................................................................1468
SNAPBP................................................................................................................................................. 1477
SNAPBP_PART....................................................................................................................................... 1482
SNAPCONTAINER - tablespace_container snapshot...........................................................................1485
SNAPDB................................................................................................................................................. 1489
SNAPDB_MEMORY_POOL.....................................................................................................................1502
SNAPDBM.............................................................................................................................................. 1507
SNAPDBM_MEMORY_POOL..................................................................................................................1511
SNAPDETAILLOG...................................................................................................................................1515
SNAPFCM...............................................................................................................................................1518
SNAPFCM_PART.................................................................................................................................... 1521
SNAPHADR............................................................................................................................................ 1524
SNAPLOCK............................................................................................................................................. 1528
SNAPLOCKWAIT....................................................................................................................................1533
SNAPDB................................................................................................................................................. 1539
SNAPUTIL.............................................................................................................................................. 1552
SNAPSTMT.............................................................................................................................................1556
SNAPSTORAGE_PATHS.........................................................................................................................1562
SNAPTAB............................................................................................................................................... 1566
SNAPTBSP............................................................................................................................................. 1569
SNAPTBSP_PART...................................................................................................................................1575
SNAPTBSP_QUIESCER.......................................................................................................................... 1580
SNAPTBSP_RANGE................................................................................................................................1584
SNAPUTIL.............................................................................................................................................. 1588
SYSINSTALLROUTINES.........................................................................................................................1592
TBSP_UTILIZATION.............................................................................................................................. 1592
WLM_GET_ACTIVITY_DETAILS............................................................................................................1595
WLM_GET_SERVICE_CLASS_AGENTS_V97......................................................................................... 1601
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES_V97........................................................1608
WLM_GET_SERVICE_SUBCLASS_STATS_V97..................................................................................... 1611
WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V97................................................................. 1617
WLM_GET_WORKLOAD_STATS_V97....................................................................................................1620
Index.............................................................................................................. 1625
ix
x
Figures
xi
xii
Tables
3. Valid file type modifiers for the export utility: All file formats................................................................... 29
4. Valid file type modifiers for the export utility: DEL (delimited ASCII) file format..................................... 30
5. Valid file type modifiers for the export utility: IXF file format................................................................... 33
7. Valid file type modifiers for the import utility: All file formats...................................................................49
8. Valid file type modifiers for the import utility: ASCII file formats (ASC/DEL)............................................53
9. Valid file type modifiers for the import utility: ASC (non-delimited ASCII) file format............................. 58
10. Valid file type modifiers for the import utility: DEL (delimited ASCII) file format...................................59
11. Valid file type modifiers for the import utility: IXF file format................................................................. 60
17. Valid file type modifiers for the load utility: All file formats.................................................................... 85
18. Valid file type modifiers for the load utility: ASCII file formats (ASC/DEL)............................................. 92
19. Valid file type modifiers for the load utility: ASC file formats (Non-delimited ASCII)............................ 97
20. Valid file type modifiers for the load utility: DEL file formats (Delimited ASCII).................................... 99
21. Valid file type modifiers for the load utility: IXF file format...................................................................100
xiii
24. ADMIN_DROP_SCHEMA errortab format............................................................................................... 147
40. Key and value pairs returned by the ADMIN_MOVE_TABLE stored procedure....................................205
46. Field names and values for the UNIX cron format.................................................................................250
47. Example task schedules and the appropriate schedule argument values........................................... 251
xiv
48. Information returned by the ADMIN_TASK_LIST administrative view.................................................252
50. Information returned by the AUDIT_ARCHIVE procedure and table function..................................... 259
52. Common SQL API shared input and output parameters....................................................................... 266
53. Information returned by the DESIGN_ADVISOR - retrieve design advisor recommendations table
function.................................................................................................................................................... 278
56. Information returned by the DBCFG administrative view and the DB_GET_CFG table function..........312
57. Information returned by the DBMCFG administrative view and DBM_GET_CFG table function..........317
65. Possible values for the NAME and DATATYPE columns........................................................................ 328
xv
73. Information returned by the ENV_INST_INFO administrative view..................................................... 344
xvi
97. Metric names returned by MON_FORMAT_XML_METRICS_BY_ROW for XML documents
containing an activity_metrics element type.......................................................................................... 437
115. List of CF commands that are monitored by the MON_GET_CF_CMD function.................................. 528
117. List of CF commands that are monitored by the MON_GET_CF_WAIT_TIME function...................... 530
xvii
120. Detailed metrics returned for MON_GET_CONNECTION_DETAILS....................................................552
xviii
145. Information returned for MON_GET_ROUTINE_DETAILS.................................................................. 695
xix
170. Detailed metrics returned for MON_GET_UNIT_OF_WORK_DETAILS................................................867
193. Information returned by the SNAPDYN_SQL administrative view and the SNAP_GET_DYN_SQL
table function........................................................................................................................................... 978
xx
195. Information returned by the SNAPSWITCHES administrative view and the
SNAP_GET_SWITCHES table function.....................................................................................................986
198. Information returned by the SNAPDYN_SQL administrative view and the SNAP_GET_DYN_SQL
table function......................................................................................................................................... 1001
215. Elements of a compilation environment returned by the COMPILATION_ENV table function....... 1111
xxi
217. Information returned by the CONTACTS administrative view.......................................................... 1114
220. Information returned by the DBPATHS administrative view and the ADMIN_LIST_DB_PATHS
table function......................................................................................................................................... 1121
227. Deprecated SQL administrative routines or views and their replacement routines or views.......... 1151
xxii
241. Information returned by the BP_HITRATIO administrative view..................................................... 1205
xxiii
266. Information returned by the HEALTH_TBS_HI table function..........................................................1259
275. Information returned by the SNAPAGENT administrative view and the SNAP_GET_AGENT table
function.................................................................................................................................................. 1282
279. Information returned by the SNAPAPPL administrative view and the SNAP_GET_APPL table
function.................................................................................................................................................. 1303
281. Information returned by the SNAPBP administrative view and the SNAP_GET_BP table function.1319
282. Information returned by the SNAPBP_PART administrative view and the SNAP_GET_BP_PART
table function......................................................................................................................................... 1324
286. Information returned by the SNAPDB administrative view and SNAP_GET_DB table function...... 1339
xxiv
288. Information returned by the SNAP_GET_DB_V97 table function..................................................... 1355
289. Information returned by the SNAPDBM administrative view and the SNAP_GET_DBM table
function.................................................................................................................................................. 1365
295. Information returned by the SNAPFCM administrative view and the SNAP_GET_FCM table
function.................................................................................................................................................. 1385
297. Information returned by the SNAPHADR administrative view and the SNAP_GET_HADR table
function.................................................................................................................................................. 1391
298. Information returned by the SNAPLOCK administrative view and the SNAP_GET_LOCK table
function.................................................................................................................................................. 1395
301. Information returned by the SNAPSTMT administrative view and the SNAP_GET_STMT table
function.................................................................................................................................................. 1411
304. Information returned by the SNAPTAB administrative view and the SNAP_GET_TAB table
function.................................................................................................................................................. 1421
306. Information returned by the SNAPTBSP administrative view and the SNAP_GET_TBSP table
function.................................................................................................................................................. 1427
xxv
307. Information returned by the SNAPTBSP_PART administrative view and the
SNAP_GET_TBSP_PART table function..................................................................................................1433
311. Information returned by the SNAPUTIL administrative view and the SNAP_GET_UTIL table
function.................................................................................................................................................. 1450
312. Information returned by the SNAPAGENT administrative view and the SNAP_GET_AGENT table
function.................................................................................................................................................. 1455
315. Information returned by the SNAPAPPL administrative view and the SNAP_GET_APPL table
function.................................................................................................................................................. 1471
316. Information returned by the SNAPBP administrative view and the SNAP_GET_BP table function.1479
317. Information returned by the SNAPBP_PART administrative view and the SNAP_GET_BP_PART
table function......................................................................................................................................... 1485
319. Information returned by the SNAPDB administrative view and SNAP_GET_DB table function...... 1493
321. Information returned by the SNAPDBM administrative view and the SNAP_GET_DBM table
function.................................................................................................................................................. 1509
324. Information returned by the SNAPFCM administrative view and the SNAP_GET_FCM table
function.................................................................................................................................................. 1520
xxvi
326. Information returned by the SNAPHADR administrative view and the SNAP_GET_HADR table
function.................................................................................................................................................. 1526
327. Information returned by the SNAPLOCK administrative view and the SNAP_GET_LOCK table
function.................................................................................................................................................. 1531
329. Information returned by the SNAPDB administrative view and SNAP_GET_DB table function...... 1543
330. Information returned by the SNAPUTIL administrative view and the SNAP_GET_UTIL table
function.................................................................................................................................................. 1555
331. Information returned by the SNAPSTMT administrative view and the SNAP_GET_STMT table
function.................................................................................................................................................. 1559
333. Information returned by the SNAPTAB administrative view and the SNAP_GET_TAB table
function.................................................................................................................................................. 1568
334. Information returned by the SNAPTBSP administrative view and the SNAP_GET_TBSP table
function.................................................................................................................................................. 1572
338. Information returned by the SNAPUTIL administrative view and the SNAP_GET_UTIL table
function.................................................................................................................................................. 1591
xxvii
346. Information returned for WLM_GET_SERVICE_SUBCLASS_STATS_V97......................................... 1614
xxviii
Chapter 1. Built-in routines and views
Built-in administrative routines and views provide a simplified programmatic interface to administer and
use databases and database objects through structured query language (SQL).
Built-in routines encompass procedures, scalar functions, and table functions.
You can run these built-in routines and views from an SQL-based application, a command line, or a
command script.
Character and graphic strings that are used as parameters of routines or returned from the routines or
views are always in OCTETS even when the environment is set to CODEUNITS32.
Instead, name the result columns in the SELECT statement. This technique gives the application control
over the number of result columns and the sequence in which they are returned. In the following rewrite
of the previous query, the columns are named:
SELECT application_handle,
uow_id,
total_cpu_time,
app_rqsts_completed_total,
rqsts_completed_total
FROM TABLE(MON_GET_UNIT_OF_WORK(NULL,-1)) AS t
ORDER BY total_cpu_time DESC
Naming columns prevents problems if the sequence and number of columns in the routines change. The
number of result columns that a routine returns might increase. If, for example, you provide only five host
variables when the routine returns six result columns, your application will break.
In addition, the type and size of output parameters or result columns of routines might change. For
example, a column might change from VARCHAR(8) to VARCHAR(128), or an INTEGER column might
become a BIGINT column. If a variable that you use is too small, the data that you receive from the
routine might be truncated.
To protect your C application from such changes, you can describe a prepared statement to determine
which result columns are returned and what their types and sizes are. The following example shows how
to describe a prepared statement:
For an example of how to use the information that is returned in the SQL description area (SQLDA), see
the RowDatamemoryAlloc function in the samples/c/tbread.sqc file.
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData rsms = rs.getMetaData();
For an example of how to use the metadata of the result set, see the
execPreparedQueryWithUnknownOutputColumn( ) method in the samples/java/jdbc/
TbRead.java file.
Built-in routines
For all built-in routines in the SYSPROC schema, you need EXECUTE privilege on the routine. You can use
the following query to check whether your authorization ID, or a group or a role to which you belong, has
EXECUTE privilege:
Built-in views
For all built-in views in the SYSIBMADM schema, you need SELECT privilege on the view. You can use the
following query to check whether your authorization ID, or a group or a role to which you belong, has
SELECT privilege:
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
One of the following authorities is required to execute the routine:
Usage notes
Retrieving command execution information:
• As the ADMIN_CMD procedure runs on the server, the utility messages are also created on the server.
The MESSAGES ON SERVER option (refer to the specific command for further details) indicates that the
message file is to be created on the server.
• Command execution status is returned in the SQLCA resulting from the CALL statement.
• If the execution of the administrative command is successful, and the command returns more than the
execution status, the additional information is returned in the form of a result set (up to two result sets).
For example, if the EXPORT command executes successfully, the returned result set contains
information about the number of exported rows; however, if the RUNSTATS command executes
successfully, no result set is returned. The result set information is documented with the corresponding
command.
• If the execution of the administrative command is not successful, an SQL20397W warning message is
returned by the ADMIN_CMD procedure along with a result set containing more details about the reason
for the failure of the administrative command. Any application that uses the ADMIN_CMD procedure
should check the SQLCODE returned by the procedure. If the SQLCODE is >= 0, the result set for the
administrative command should be retrieved. The following table indicates what information might be
returned depending on whether the MESSAGES ON SERVER option is used or not.
Authorization
None
Required connection
Command syntax
ADD CONTACT name TYPE
EMAIL ADDRESS
PAGE
MAXIMUM PAGE LENGTH pg-length
MAX LEN
recipients address
DESCRIPTION contact description
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 wants to be notified by email at (ADDRESS).
PAGE
This contact wants 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.
The notification system uses the SMTP protocol to send the notification to the mail server
specified by the Db2 Administration Server configuration parameter smtp_server. It is the
responsibility of the SMTP server to send the email or call the pager.
ADDRESS recipients-address
The SMTP mailbox address of the recipient. For example, [email protected]. The smtp_server
DAS configuration parameter must be set to the name of the SMTP server.
DESCRIPTION contact description
A textual description of the contact. This has a maximum length of 128 characters.
Authorization
None
Required connection
Command Syntax
,
GROUP
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.
Authorization
SYSADM
Required connection
Database
Command syntax
AUTOCONFIGURE autoconfigure-clause
autoconfigure-clause:
apply-clause:
APPLY DB ONLY
ON CURRENT MEMBER report-clause
DB AND DBM
ON CURRENT MEMBER
NONE
report-clause
REPORT FOR MEMBER -1
MEMBER member-number1
,
MEMBERS ( member-number2 )
Command parameters
USING input-keyword param-value
Usage notes
• This command makes configuration recommendations for the currently connected database and
assumes that the database is the only active database on the instance. If you have not enabled the self
tuning memory manager and you have more than one active database on the instance, specify a
mem_percent value that reflects the database memory distribution. For example, if you have two
active databases on the instance that should use 80% of the instance memory and should share the
resources equally, specify 40% (80% divided by 2 databases) as the mem_percent value.
• If you have multiple instances on the same computer and the self tuning memory manager is not
enabled, you should set a fixed value for instance_memory on each instance or specify a
mem_percent value that reflects the database memory distribution. For example, if all active
databases should use 80% of the computer memory and there are 4 instances each with one database,
specify 20% (80% divided by 4 databases) as the mem_percent value.
• When explicitly invoking the Configuration Advisor with the AUTOCONFIGURE command, the setting of
the DB2_ENABLE_AUTOCONFIG_DEFAULT registry variable will be ignored.
Compatibilities
For compatibility with previous versions:
• NODE and DBPARTITIONNUM can be specified in place of MEMBER, except when the
DB2_ENFORCE_MEMBER_SYNTAX registry variable is set to ON.
Scope
In a partitioned database environment, if no database partitions are specified, this command affects only
the database partition on which it is run.
If the option to perform a partitioned backup is specified, the command can be called only on the catalog
database partition. If the option specifies that all database partition servers are to be backed up, it affects
all database partition servers that are listed in the db2nodes.cfg file. Otherwise, it affects the database
partition servers that are specified on the command.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
Required connection
DB
DBPARTITIONNUMS
ALL DBPARTITIONNUMS
EXCEPT DBPARTITIONNUM Partition number(s)
DBPARTITIONNUMS
TABLESPACE ( tablespace-name )
NO TABLESPACE
INCREMENTAL
DELTA
XBSA
SNAPSHOT
LIBRARY library-name
SCRIPT script-name
TO dir
dev
remote-storage
COMPRESS
COMPRLIB name EXCLUDE COMPROPTS string
ENCRYPT
ENCRLIB name EXCLUDE ENCROPTS string
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.
ON
Back up the database on a set of database partitions.
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 that are specified in the
db2nodes.cfg file.
EXCEPT
Specifies that the database is to be backed up on all partitions that are 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.
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.
TABLESPACE tablespace-name
A list of names that are used to specify the table spaces to be backed up.
NO TABLESPACE
Specifies a metadata-only backup. A metadata-only backup does not contain any tablespace data.
Among the metadata that it does contain is the database's recovery history file. This file can be
restored by using the HISTORY FILE option of the RESTORE DATABASE command.
ONLINE
INCREMENTAL
Specifies a cumulative (incremental) backup image. An incremental backup image is a copy of all
database data that changed since the most recent successful, full backup operation.
DELTA
Specifies a noncumulative (delta) backup image. A delta backup image is a copy of all database
data that changed since the most recent successful backup operation of any type.
DB2REMOTE://<alias>//<storage-path>
In a partitioned database, the target directory or device must exist on all database partitions, and can
optionally be a shared path. The directory or device name can be specified by using a database
partition expression. For more information about database partition expressions, see "Automatic
storage databases".
This parameter can be repeated to specify the target directories and devices that the backup image
spans. If more than one target is specified (target1, target2, and target3, for example), target1 is
opened first. The media header and special files (including the configuration file, table space table,
and history file) are placed in target1. All remaining targets are opened, and are then used in parallel
during the backup operation. Because there is no general tape support on Windows operating
systems, each type of tape device requires a unique device driver.
If the tape system does not support the ability to uniquely reference a backup image, multiple backup
copies of the same database must not be kept on the same tape.
LOAD library-name
The name of the shared library (DLL on Windows operating systems) containing the vendor backup
and restore I/O functions to be used. It can contain the full path. If the full path is not given, it
defaults to the path on which the user exit program resides.
DEDUP_DEVICE
Optimizes the format of the backup images for target storage devices that support data deduplication.
WITH num-buffers BUFFERS
The number of buffers to be used. If the number of buffers that you specify is not enough to create a
successful backup, then the minimum value necessary to complete the backup is automatically
chosen for this parameter. If you are backing up to multiple locations, you can specify a larger number
of buffers to improve performance. If you specify the COMPRESS parameter, to help improve
performance, you can add an extra buffer for each table space that you specify for the PARALLELISM
parameter.
BUFFER buffer-size
The size, in 4 KB pages, of the buffer used when building the backup image. Db2 automatically
chooses an optimal value for this parameter unless you explicitly enter a value. The minimum value
for this parameter is eight pages.
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 that can be read in parallel by the backup utility. Db2
automatically chooses an optimal value for this parameter unless you explicitly enter a value.
UTIL_IMPACT_PRIORITY priority
Specifies that the backup runs 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 runs with the default
priority of 50. If UTIL_IMPACT_PRIORITY is not specified, the backup runs 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|ENCRYPT
Indicates that the backup is to be compressed or encrypted. You cannot specify both parameters
simultaneously. The COMPRESS and ENCRYPT parameters are synonyms and can be used
interchangeably only when either COMPRLIB or ENCRLIB is specified too. If you specify COMPRESS
without COMPRLIB, the default compression library libdb2compr.so is used for compression. If you
specify ENCRYPT without ENCRLIB, the default encryption library libdb2encr.so is used for
encryption. If you want to specify another library, you can use COMPRESS and ENCRYPT
interchangeably. You can use either COMPRLIB or ENCRLIB to specify the libdb2compr_encr.so
library. If the encrlib database configuration parameter is set to a non-NULL value, neither
COMPRLIB nor ENCRLIB can be specified. If encrlib database configuration parameter is not set, a
specified ENCROPTS command option will be used rather than encropts database configuration
parameter. If the encrlib and encropts database configuration parameters are set to a non-NULL
value, neither COMPROPTS nor ENCROPTS can be specified on the command.
Note: For databases which are natively encrypted, data is decrypted prior to backup. Encryption of
the backup can be achieved by using this ENCRYPT parameter of the BACKUP DATABASE command.
Encryption of the backup can also be achieved through the encrlib database configuration
parameter. The backup will be encrypted using the algorithm employed by the specified encryption
library, independent of any database native encryption configured cipher or algorithm.
COMPRLIB|ENCRLIB name
Indicates the name of the library that is used during the compression or encryption process. For
example, db2compr.dll for Windows; libdb2compr.so for Linux and UNIX operating systems.
The name must be a fully qualified path that refers to a file on the server. If this parameter is not
specified, the default Db2 compression library is used. If the specified library cannot be loaded,
the backup operation fails.
EXCLUDE
Indicates that the library is not stored in the backup image.
COMPROPTS|ENCROPTS string
Describes a block of binary data that is passed to the initialization routine in the library. The
database manager passes this string directly from the client to the server. Any issues of byte
reversal or code page conversion are handled by the compression library. If the first character of
the data block is '@', the rest of the data is interpreted as the name of a file on the server. The
database manager then replaces the contents of the string with the contents of this file and
passes this new value to the initialization routine. The maximum length for string is 1024 bytes.
Cipher=cipher-name:Mode=mode-name:Key Length=key-length:
Master Key Label=label-name-1...:Master Key Label=label-name-n
• Cipher is optional. Valid values are AES and 3DES (the default is AES).
• Mode is optional. The default is CBC.
• Key length is optional. Valid values for AES are 128, 192, and 256 (the default is 256), and the
only valid value for 3DES is 168.
• Master key label is optional. The default is the database master key label.
If you are using other libraries, the format of the ENCROPTS string depends on those libraries.
EXCLUDE LOGS
Specifies that the backup image must not include any log files. When you performe an offline backup
operation, logs are excluded whether this option is specified, except for snapshot backups.Logs are
excluded by default in the following backup scenarios:
• Offline backup of a single-partitioned database.
• Online or offline backup of a multi-partitioned database, when not using a single system view
backup.
If you specify the EXCLUDE LOGS with a snapshot backup, writes to log files are allowed during the
backup. These log files are included by default in the snapshot backup, but are not usable for
recovery. If this backup is restored, the log files must not be extracted from the backup. If the log
path was set to the default when the backup was taken, then it is not possible to exclude the log files
from being restored and they must be deleted manually after the backup is restored. If the log path
was not the default, then the log files can be excluded at restore time by using the LOGTARGET
EXCLUDE options with the RESTORE DATABASE command.
INCLUDE LOGS
Specifies that the backup image must include the range of log files that are required to restore and roll
forward this image to some consistent point in time. This option is not valid for an offline backup,
except for snapshot backups. INCLUDE LOGS always the default option for any online backup
operation, except a multi-partitioned online backup where each database partition is backed up
independently (that is, a non-single system view backup).
If any of the log files that are required for the backup have previously been backed up and are no
longer in the log path, then the Db2 database manager retrieves them for backup from the overflow
log path, if the path has been set. Otherwise, the database manager retrieves them for backup from
the current log path or mirror log path. These log files are removed from the log path after the backup
is complete.
WITHOUT PROMPTING
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 backing up to tape, use of a variable block size is not supported. If you must use this option,
ensure that you have tested procedures in place that enable you to recover successfully, using backup
images that were created with a variable block size.
• The backup utility cannot be used with a Type 2 connection.
• 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.
Authorization
The authorization required depends on the type of information you want to display using the DESCRIBE
command.
• If the SYSTOOLSTMPSPACE table space exists, one of the authorities shown in the following table is
required.
OUT and INOUT parameters of a CALL statement Any of the following privileges or authorities:
– DATAACCESS authority
– EXECUTE privilege on the stored procedure
– EXECUTEIN privilege on the schema containing
the stored procedure
– DATAACCESS authority on the schema
containing the stored procedure
• If the SYSTOOLSTMPSPACE table space does not exist, SYSADM or SYSCTRL authority is also required
in addition to the one of the previously listed authorities.
Required connection
OUTPUT
select-statement
call-statement
XQUERY XQuery-statement
TABLE table-name
RELATIONAL DATA
XML DATA
TEXT SEARCH
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 statement, precede the statement with the keyword
XQUERY. A DESCRIBE OUTPUT statement only returns information about an implicitly hidden
column if the column is explicitly specified as part of the SELECT list of the final result table of the
query described.
TABLE table-name
Specifies the table or view to be described. The fully qualified name in the form schema.table-name
must be used. An alias for the table cannot be used in place of the actual table. Information about
implicitly hidden columns is returned, but SHOW DETAIL must be used to indicate which columns are
implicitly hidden.
The DESCRIBE TABLE command lists the following information about each column:
• Column name
• Type schema
• Type name
• Length
• Scale
• Nulls (yes/no)
INDEXES FOR TABLE table-name
Specifies the table or view for which indexes need to be described. You can use the fully qualified
name in the form schema.table-name or you can just specify the table-name and default schema will
be used automatically. An alias for the table cannot be used in place of the actual table.
The DESCRIBE INDEXES FOR TABLE command lists the following information about each index of
the table or view:
• Index schema
• Index name
• Unique rule
• Number of columns
• Index type
Authorization
None
Required connection
Command syntax
DROP CONTACT name
Command parameters
CONTACT name
The name of the contact that will be dropped from the local system.
Authorization
None
Required Connection
Command Syntax
DROP CONTACTGROUP name
Command Parameters
CONTACTGROUP name
The name of the contact group that will be dropped from the local system.
Authorization
One of the following authorities:
• DATAACCESS authority on the schema of each participating table or view
• DATAACCESS authority on the database
• SELECTIN privilege on the schema of each participating table or view
Required connection
Command syntax
EXPORT TO filename OF filetype
,
LOBS TO lob-path
, ,
XMLSAVESCHEMA ,
METHOD N ( column-name )
select-statement
XQUERY xquery-statement
traversal-order-list
WHERE
traversal-order-list
,
( sub-table-name )
Command parameters
TO filename
If the name of a file that exists is specified, the export utility overwrites the contents of the file; it does
not append the information.
OF filetype
Specifies the format of the data in the output file:
• DEL (delimited ASCII format), which is used by various database manager and file manager
programs.
• IXF (Integration Exchange Format, PC version) is a proprietary binary format.
LOBS TO lob-path
Specifies one or more paths to directories in which the LOB files are to be stored. There must be at
least one file per LOB path, and each file must contain at least one LOB. The maximum number of
paths that can be specified is 999. This setting implicitly activates the LOBSINFILE behavior.
• Use the DB2_DMU_DEFAULT registry variable on the client-side to set the default behavior when
data movement utilities encounter tables with implicitly hidden columns.
db2set DB2_DMU_DEFAULT=IMPLICITLYHIDDENINCLUDE
db2 export to t.del of del select * from t
Usage notes
• Be sure to complete all table operations and release all locks before you start an export operation. This
step can be done by issuing a COMMIT after you close all cursors opened WITH HOLD, or by issuing a
ROLLBACK.
• Table aliases can be used in the SELECT statement.
• You might encounter the SQL27981W message when it does not seem applicable, such as when the
EXPORT table is not partitioned. You can safely ignore this warning in this case. This warning message
might be returned if the SELECT statement of the EXPORT command includes the word ' from ' before
the SQL keyword FROM.
• The messages that are placed in the message file include the information that is returned from the
message retrieval service. Each message begins on a new line.
• PC/IXF import must be used to move data between databases. If character data that contains row
separators is exported to a delimited ASCII (DEL) file and processed by a text transfer program, fields
that contain the row separators shrinks or expands.
• The file copying step is not necessary if the source and the target databases are both accessible from
the same client.
• Db2 Connect can be used to export tables from DRDA servers such as Db2 for z/OS®, Db2 for VM and
VSE, and Db2 for OS/400®. Only PC/IXF export is supported.
• When you export to the IXF format, if identifiers exceed the maximum size that is supported by the IXF
format, the export succeeds. However, the resulting datafile cannot be used by a subsequent import
operation by using the CREATE mode (SQL27984W).
• When you export to the IXF format, the export utility does not maintain column-organized table
metadata that is needed to re-create the column-organized table during a subsequent import operation
by using the CREATE mode.
• When you export to a diskette on Windows, and the table that has more data than the capacity of a
single diskette, the system prompts for another diskette. Multiple-part PC/IXF files (also known as
multi-volume PC/IXF files, or logically split PC/IXF files), are generated and stored in separate
diskettes. In each file, with the exception of the last, there is a Db2 CONTINUATION RECORD (or "AC"
Record in short) written. This record indicates that the files are logically split and shows where to look
for the next file. The files can then be transferred to an AIX® system to be read by the import and load
utilities. The export utility will not create multiple-part PC/IXF files when invoked from an AIX system.
For detailed usage, see the IMPORT command or LOAD command.
• The export utility stores the NOT NULL WITH DEFAULT attribute of the table in an IXF file if the SELECT
statement provided is in the form SELECT * FROM tablename.
But an export command that uses the same select clause will not:
Now, replacing the LOCALE date format with ISO format gives the expected results:
Table 3. Valid file type modifiers for the export utility: All file formats
Modifier Description
lobsinfile lob-path specifies the path to the files that contain LOB 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 that is 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 at offset
123 in the file db2exp.001, and is 456 bytes long.
If you specify the lobsinfile modifier when you use EXPORT, the LOB data
is placed in the locations that are 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
is at least one file per LOB path, and each file contains at least one LOB. The
LOBS TO or LOBFILE options implicitly activates 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/.
implicitlyhiddeninclud This modifier is used with SELECT * queries and specifies that the data in
e implicitly hidden columns is exported even though that data is not included in
the result of the SELECT * query. This modifier cannot be used with the
implicitlyhiddenmissing modifier.
If this modifier is used and the query is not a SELECT *, then an error is
returned (SQLCODE SQL3526N).
This modifier does not apply to the hidden RANDOM_DISTRIBUTION_KEY
column of a random distribution tables that uses the random by generation
method. The column must be explicitly referenced in the query to be included
in the exported data.
implicitlyhiddenmissin This modifier is used with SELECT * queries and specifies that the data in
g implicitly hidden columns is not exported. This modifier cannot be used with
the implicitlyhiddeninclude modifier.
If this modifier is used and the query is not a SELECT *, then an error is
returned (SQLCODE SQL3526N).
This modifier does not apply to the hidden RANDOM_DISTRIBUTION_KEY
column of a random distribution tables that uses the random by generation
method. The column must be explicitly referenced in the query to be included
in the exported data.
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.
Table 4. 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 must 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''
codepage=x x is an ASCII character string. The value is interpreted as the code page of the
data in the output data set. Converts character data from the application code
page to this code page during the export operation.
For pure DBCS (graphic), mixed DBCS, and EUC, delimiters are restricted to the
range of x00 to x3F, inclusive.
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:
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 is not surrounded by character delimiters. This option must not
be specified if the data is intended to be imported or loaded by 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
options are mutually exclusive.
In the first export operation, the content of the exported file data are
+00000000000000000000000000001.10. In the second operation, which is
identical to the first except for the striplzeros modifier, the content of the
exported file data are +1.10.
"YYYY/MM/DD HH:MM:SS.UUUUUU"
The MMM element produces 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.
The following example illustrates how to export data that contains user-
defined time stamp formats from a table called 'schedule':
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 step 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
• date data in YYYYMMDD format
• char(date) data in "YYYY-MM-DD" format
• time data in "HH.MM.SS" format
• time stamp data in "YYYY-MM-DD-HH.MM.SS.uuuuuu" format
Data that is contained in any datetime columns that are specified in the SELECT statement for the
export operation are also 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 next to other date fields. A
minute field must be next to other time fields. Following are some ambiguous time stamp formats:
In ambiguous cases, the utility reports an error message, and the operation fails.
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. All XDM instances are written to XML files that are separate from the main data file, even if the
XMLFILE and XML TO clauses are not specified. By default, XML files are written to the path of the
exported data file. The default base name for XML files is the name of the exported data file with the
extension ".XML" appended to it.
6. All XDM instances are written with an XML declaration at the beginning that includes an encoding
attribute, unless the XMLNODECLARATION file type modifier is specified.
7. By default, all XDM instances are written in Unicode unless the XMLCHAR or XMLGRAPHIC file type
modifier is specified.
8. The default path for XML data and LOB data is the path of the main data file. The default XML file base
name is the main data file. The default LOB file base name is the main data file. For example, if the
main data file is:
/mypath/myfile.del
The default path for XML data and LOB data is:
myfile.del
myfile.del
The LOBSINFILE file type modifier must be specified in order to have LOB files generated.
9. 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 zeros (for example,
the 1000th LOG file or XML file will have an extension of:
.1000
Following the numeric identifier is a three character type identifier that represents the data type,
either:
.lob
or
.xml
For example, a generated LOB file would have a name in the format:
myfile.del.001.lob
myfile.del.001.xml
10. It is possible to have the export utility export XDM instances that are not well-formed documents by
specifying an XQuery. However, you cannot import or load these exported documents directly into an
XML column, since XML columns can contain only complete documents.
Scope
This command affects all database partitions that are listed in the $HOME/sqllib/db2nodes.cfg file.
In a partitioned database environment, this command does not have to be issued from the coordinator
database partition of the application being forced. It can be issued from any database partition server in
the partitioned database environment.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
Required connection
Command syntax
FORCE APPLICATION ALL
, MODE ASYNC
( application-handle )
Command parameters
FORCE APPLICATION
ALL
All applications will be disconnected from the database server.
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 returning; it returns as
soon as the function has been successfully issued or an error (such as invalid syntax) is discovered.
This is the only mode that is currently supported.
Examples
The following example forces two users, with application-handle values of 41408 and 55458, to
disconnect from the database:
Usage notes
The database manager remains active so that subsequent database manager operations can be handled
without the need for db2start.
To preserve database integrity, only users who are idling or executing interruptible database operations
can be terminated.
The following types of users and applications cannot be forced:
• users creating a database
• system applications
In order to successfully force these types of users and applications, the database must be deactivated
and/or the instance restarted.
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.
Authorization
The privileges held by the authorization ID of the statement must include at least one of the following
authorities or privilege:
• DBADM
• SECADM
Required connection
Database
Command syntax
GET STMM TUNING MEMBER
Example
Result set 1
--------------
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 member number
(USER_PREFERRED_NUMBER) is set by the user and specifies the member on which the user wants to
run the memory tuner. While the database is running, the tuning member is applied 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 member. 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.
Compatibilities
For compatibility with previous versions:
• DBPARTITIONNUM can be substituted for MEMBER, except when the DB2_ENFORCE_MEMBER_SYNTAX
registry variable is set to ON.
Authorization
• IMPORT using the INSERT option requires one of the following authorities:
– DATAACCESS authority
– DATAACCESS authority on the schema of each participating table or view
– INSERTIN and SELECTIN privilege on the schema of each participating table or view
– CONTROL privilege on each participating table, view, or nickname
– INSERT and SELECT privilege on each participating table or view
• IMPORT to an existing table using the INSERT_UPDATE option, requires one of the following authorities:
– DATAACCESS authority
– DATAACCESS authority on the schema of each participating table or view
– INSERTIN, SELECTIN, UPDATEIN, and DELETEIN privilege on the schema of each participating table
or view
– CONTROL privilege on each participating table, view, or nickname
– INSERT, SELECT, UPDATE and DELETE privilege on each participating table or view
• IMPORT to an existing table using the REPLACE or REPLACE_CREATE option, requires one of the
following authorities:
– DATAACCESS authority
– DATAACCESS authority on the schema of each participating table or view
– INSERTIN, SELECTIN, and DELETEIN privilege on the schema of each participating table or view
– CONTROL privilege on the table or view
– INSERT, SELECT, and DELETE privilege on the table or view
• IMPORT to a new table using the CREATE or REPLACE_CREATE option, requires one of the following
authorities:
– DBADM authority
– CREATETAB authority on the database and USE privilege on the table space, as well as one of:
- IMPLICIT_SCHEMA authority on the database, if the implicit or explicit schema name of the table
does not exist
- CREATEIN privilege or SCHEMAADM authority on the schema, if the schema name of the table
refers to an existing schema
• IMPORT to a hierarchy that does not exist using the CREATE, or the REPLACE_CREATE option, requires
one of the following authorities:
– DBADM authority
– CREATETAB authority on the database and USE privilege on the table space and one of:
Required connection
N ( column-name )
,
P ( column-position )
PRESERVE
SCHEMA schema-sqlid
SCHEMALOCATION HINTS
IGNORE ( schema-sqlid )
AUTOMATIC
RESTARTCOUNT n ROWCOUNT n
SKIPCOUNT
WARNINGCOUNT n NOTIMEOUT
REPLACE ( insert-column )
REPLACE_CREATE
hierarchy description
( insert-column )
UNDER sub-table-name
hierarchy description
ALL TABLES
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
FROM filename
OF filetype
Specifies the format of the data in the input file:
• ASC (non-delimited ASCII format)
• Use one of the hidden column file type modifiers: specify implicitlyhiddeninclude when the
input file contains data for the hidden columns, or implicitlyhiddenmissing when the input
file does not.
• Use the DB2_DMU_DEFAULT registry variable on the client-side to set the default behavior when
data movement utilities encounter tables with implicitly hidden columns.
db2set DB2_DMU_DEFAULT=IMPLICITLYHIDDENINCLUDE
db2 import from delfile1 of del insert into table1
insert-column
Specifies the name of a column in the table or the view into which data is to be inserted.
ALL TABLES
An implicit keyword for hierarchy only. When importing a hierarchy, the default is to import all tables
specified in the traversal order.
sub-table-list
For typed tables with the INSERT or the INSERT_UPDATE option, a list of sub-table names is used to
indicate the sub-tables into which data is to be imported.
HIERARCHY
Specifies that hierarchical data is to be imported.
STARTING sub-table-name
A keyword for hierarchy only, requesting the default order, starting from sub-table-name. For PC/IXF
files, the default order is the order stored in the input file. The default order is the only valid order for
the PC/IXF file format.
traversal-order-list
For typed tables with the INSERT, INSERT_UPDATE, or the REPLACE option, a list of sub-table names
is used to indicate the traversal order of the importing sub-tables in the hierarchy.
Usage notes
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:
• If it is likely that subsequent INSERT statements can be successful, a warning message is written to the
message file, and processing continues.
• 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.
If the log becomes full during a CREATE, REPLACE, or REPLACE_CREATE operation, the utility performs
an automatic COMMIT on inserted records. If the system fails, or the application interrupts the database
Column-organized tables
• The IMPORT command inherits all INSERT, UPDATE, or DELETE statement restrictions that pertain to
column-organized tables.
• The CREATE INTO parameter of the IMPORT command cannot create a column-organized table.
• Import operations against column-organized tables use the CS isolation level (which is needed for
insert operations), not the default RS isolation level, which is set when import packages are bound to
the database.
• You cannot use an IXF file that you created by exporting data from a column-organized table with the
CREATE parameter or the REPLACE_CREATE parameter of the IMPORT command.
Table 7. Valid file type modifiers for the import utility: All file formats
Modifier Description
compound=x x is a number between 1 and 100 inclusive. Uses nonatomic compound SQL to
insert the data, and x statements will be attempted each time.
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.
This modifier is incompatible with:
• INSERT_UPDATE mode
• Hierarchical tables
• Random distribution tables that use the random by generation method
• The following modifiers: usedefaults, identitymissing,
identityignore, generatedmissing, and generatedignore
generatedignore This modifier informs the import utility that data for all generated columns is
present in the data file but should be ignored. This results in all values for the
generated columns being generated by the utility. This modifier cannot be
used with the generatedmissing modifier.
Random distribution tables that use the random by generation method have
an internally generated column called the RANDOM_DISTRIBUTION_KEY. This
modifier does not apply to that column, only to other generated columns in the
table. Values for the RANDOM_DISTRIBUTION_KEY will be regenerated unless
explicitly referenced in the column list.
identityignore This modifier informs the import utility that data for the identity column is
present in the data file but should be ignored. This results in all identity values
being generated by the utility. The behavior will be the same for both
GENERATED ALWAYS and GENERATED BY DEFAULT identity columns. This
means that for GENERATED ALWAYS columns, no rows will be rejected. This
modifier cannot be used with the identitymissing modifier.
identitymissing If this modifier is specified, the utility assumes that the input data file contains
no data for the identity column (not even NULLs), and will therefore generate a
value for each row. The behavior will be the same for both GENERATED
ALWAYS and GENERATED BY DEFAULT identity columns. This modifier cannot
be used with the identityignore modifier.
implicitlyhiddeninclud If this modifier is specified, the utility assumes that the input data file contains
e data for the implicitly hidden columns and this data will also be imported. This
modifier cannot be used with the implicitlyhiddenmissing modifier. See
the Note: section for information about the precedence when multiple
modifiers are specified.
This modifier does not apply to the hidden RANDOM_DISTRIBUTION_KEY
column of a random distribution tables that uses the random by generation
method. The value for that column will be read from the input data file only if
the column was explicitly referenced in the column list.
implicitlyhiddenmissin If this modifier is specified, the utility assumes that the input data file does not
g contain data for the implicitly hidden columns and the utility will generate
values for those hidden columns. This modifier cannot be used with the
implicitlyhiddeninclude modifier. See the Note: section for information
about the precedence when multiple modifiers are specified.
This modifier does not apply to the hidden RANDOM_DISTRIBUTION_KEY
column of a random distribution tables that uses the random by generation
method. The value for that column will be read from the input data file only if
the column was explicitly referenced in the column list.
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:
• If a default value can be specified for a column, the default value is loaded
• If the column is nullable, and a default value cannot be specified for that
column, a NULL is loaded
• If the column is not nullable, and a default value cannot be specified, an
error is returned, and the utility stops processing.
seclabelname Indicates that security labels in the input source file are indicated by their
name rather than the default encoded numeric format. IMPORT will convert
the name to the appropriate security label if it exists. If no security label exists
with the indicated name for the security policy protecting the table the row is
not loaded and a warning (SQLSTATE 01H53, SQLCODE SQL3244W) is
returned.
This modifier cannot be specified if the seclabelchar modifier is specified,
otherwise the import fails and an error (SQLCODE SQL3525N) is returned.
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.
transactionidignore This modifier informs the import utility that data for the TRANSACTION START
ID column is present in the data file but should be ignored. When this modifier
is specified, the value for the TRANSACTION START ID column is generated by
the utility. This modifier cannot be used with the transactionidmissing
modifier.
transactionidmissing If this modifier is specified, the utility assumes that the input data file contains
no data for the TRANSACTION START ID columns. When this modifier is
specified, the value for the TRANSACTION START ID column is generated by
the utility. This modifier cannot be used with the transactionidignore
modifier.
Table 8. Valid file type modifiers for the import utility: ASCII file formats (ASC/DEL)
Modifier Description
codepage=x x is an ASCII character string. The value is interpreted as the code page of the
data in the input data set. Converts character data from this code page to the
application code page during the import operation.
The following rules apply:
• For pure DBCS (graphic) mixed DBCS, and EUC, delimiters are restricted to
the range of x00 to x3F, inclusive.
• nullindchar must specify symbols included in the standard ASCII set
between code points x20 and x7F, inclusive. This refers to ASCII symbols
and code points.
Note:
1. If data expansion occurs when the code page is converted from the
application code page to the database code page, the data might be
truncated and loss of data can occur.
"D-M-YYYY"
"MM.DD.YYYY"
"YYYYDDD"
"HH:MM:SS"
"HH.MM TT"
"SSSSS"
"YYYY/MM/DD HH:MM:SS.UUUUUU"
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.
56 IBM Db2 V11.5: Built-In Routines and Views
The following example illustrates how to import data containing user defined
Table 8. Valid file type modifiers for the import utility: ASCII file formats (ASC/DEL) (continued)
Modifier Description
usegraphiccodepage If usegraphiccodepage is given, the assumption is made that data being
imported into graphic or double-byte character large object (DBCLOB) data
fields is in the graphic code page. The rest of the data is assumed to be in the
character code page. The graphic code page is associated with the character
code page. IMPORT determines the character code page through either the
codepage modifier, if it is specified, or through the code page of the
application 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 code
page is the value specified by the codepage file type modifier, or the
application code page 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.
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.
In the following example, striptblanks causes the import utility to truncate
trailing blank spaces:
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.
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:
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:
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.34
In the following example, decpt; causes the import utility to interpret any
semicolon (;) it encounters as a decimal point:
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.
This option cannot be specified with chardelx, delprioritychar or
nodoubledel. These are mutually exclusive options.
Table 11. 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: The indexixf parameter has been deprecated and may be removed in
a future release. For additional details, see "IMPORT command options
CREATE and REPLACE_CREATE have been deprecated."
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.
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 statements:
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:
• indexixf
• indexschema
• dldelfiletype
• nodefaults
• usedefaults
• no_type_idfiletype
• generatedignore
• generatedmissing
• identityignore
• identitymissing
• lobsinfile
6. The CREATE mode is not supported for XML columns.
7. 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.
8. XML documents are assumed to be in Unicode format or to contain a declaration tag that includes an
encoding attribute, unless the XMLCHAR or XMLGRAPHIC file type modifier is specified.
However, changing the order of the file type modifiers in the following statement means that data for
all implicitly hidden columns (including hidden identity columns) is included in the input data. While
data for identity columns that are not implicitly hidden is not.
db2set DB2_DMU_DEFAULT=IMPLICITLYHIDDENINCLUDE
db2 import from delfile1 of del modified by identitymissing insert into table1
is equivalent to:
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
Required connection
Command syntax
INITIALIZE TAPE
ON device USING blksize
Command parameters
ON device
Specifies a valid tape device name. The default value is \\.\TAPE0.
Restrictions
The load utility does not support loading data at the hierarchy level. The load utility is not compatible with
range-clustered tables. The load utility does not support the NOT LOGGED INITIALLY parameter for the
CREATE TABLE or ALTER TABLE statements.
Scope
This command can be issued against multiple database partitions in a single request.
Authorization
One or more of the following authorities:
• DATAACCESS authority on the database
• DATAACCESS authority on the schema of the table
• LOAD authority on the database or LOAD authority on the schema and the following privileges:
– INSERT or INSERTIN privilege on the table when the load utility is invoked in INSERT mode,
TERMINATE mode (to terminate a previous load insert operation), or RESTART mode (to restart a
previous load insert operation)
– INSERT and DELETE privileges on the table or INSERTIN and DELETEIN privileges on the schema
when the load utility is invoked in REPLACE mode, TERMINATE mode (to terminate a previous load
replace operation), or RESTART mode (to restart a previous load replace operation)
– INSERT privilege on the exception table or INSERTIN privilege on the schema containing the
exception table, if such a table is used as part of the load operation.
• To load data into a table that has protected columns, the session authorization ID must have LBAC
credentials directly or indirectly through a group or a role that allow write access to all protected
columns in the table. Otherwise the load fails and an error (SQLSTATE 5U014) is returned.
Required connection
Instance. An explicit attachment is not required. If a connection to the database has been established, an
implicit attachment to the local instance is attempted.
remotefilename
pipename
device
, ,
MODIFIED BY file-type-mod
N ( col-name )
,
P ( col-position )
PRESERVE
SCHEMA schema-sqlid
SCHEMALOCATION HINTS
IGNORE ( schema-sqlid )
KEEPDICTIONARY
REPLACE
RESETDICTIONARY
RESETDICTIONARYONLY
RESTART
TERMINATE
( insert-column )
12
,
NOUNIQUEEXC
3
STATISTICS NO
NO
TO device/directory
LOAD lib-name
OPEN num-sess SESSIONS
NONRECOVERABLE
CPU_PARALLELISM n DISK_PARALLELISM n
REBUILD
INCREMENTAL
DEFERRED
ALLOW NO ACCESS
YES
FETCH_PARALLELISM NO
DEFERRED
PARTITIONED DB CONFIG
partitioned-db-option
Notes:
1 These keywords can appear in any order.
2 Each of these keywords can appear only once.
3 For column-organized tables, the default is the STATISTICS USE PROFILE parameter.
Command parameters
FROM filename | remotefilename | pipename | device
A remotefilename refers to a file that is on remote storage, such as IBM Cloud Object Storage or
Amazon Simple Storage Service (S3), and is being accessed using a storage access alias. Local staging
space is required to temporarily store the file that is transferred from the remote storage server; refer
to Remote storage requirements. The syntax of remote file names is:
DB2REMOTE://<alias>//<storage-path>/<file-name>
Note:
• If data is exported into a file using the EXPORT command using the ADMIN_CMD procedure, the
data file is owned by the fenced user ID. This file is not usually accessible by the instance owner. To
run the LOAD from CLP or the ADMIN_CMD procedure, the data file must be accessible by the
instance owner ID, so read access to the data file must be granted to the instance owner.
• Loading data from multiple IXF files is supported if the files are physically separate, but logically
one file. It is not supported if the files are both logically and physically separate. If more than one
logically and physically separate files are specified, then any file after the first one is ignored.
(Multiple physical files would be considered logically one if they were all created with one
invocation of the EXPORT command.)
• When loading XML data from files into tables in a partitioned database environment, the XML data
files must be read-accessible to all the database partitions where loading is taking place.
OF filetype
Specifies the format of the data:
• ASC (non-delimited ASCII format)
• DEL (delimited ASCII format)
• IXF (Integration Exchange Format, PC version) is a binary format that is used exclusively by Db2
databases.
• CURSOR (a cursor declared against a SELECT or VALUES statement).
Note:
• When using a CURSOR file type to load XML data into a table in a distributed database environment,
the PARTITION_ONLY and LOAD_ONLY modes are not supported.
• When performing a load using the CURSOR file type where the DATABASE keyword was specified
during the DECLARE CURSOR statement, load internally creates a separate application to fetch the
data; whereas when the DATABASE keyword is not specified, load fetches data within the same
application. This difference between the two cases can also cause locking behavior difference. In
particular, if you currently specify the DATABASE keyword using the same database as the currently
connected database (and same userid and password as the current connection, if specified), there
might be cases where you get into a lock issue (such as a lock wait or lock timeout, depending on
the database configuration) which can be worked around by omitting the DATABASE keyword.
Note:
1. A compression dictionary can be created for the XML storage object of a table only if the XML
columns are added to the table in Db2 Version 9.7 or later, or if the table is migrated using an
online table move.
2. If LOAD REPLACE KEEPDICTIONARY operation is interrupted, load utility can recover after
either LOAD RESTART or LOAD TERMINATE is issued. Existing XML storage object dictionary
may not be preserved after recovery from interrupted LOAD REPLACE KEEPDICTIONARY
operation. A new XML storage object dictionary will be created if LOAD RESTART is used
RESETDICTIONARY
This directive instructs LOAD REPLACE processing to build a new dictionary for the table data
object, provided that the table COMPRESS attribute is YES.
If the COMPRESS attribute is NO and a dictionary was already present in the table it will be
removed and no new dictionary will be inserted into the table.
This option is the default for column-organized tables.
For column-organized tables, you cannot specify LOAD REPLACE … RESETDICTIONARY on a
subset of database partitions (SQL27906N). If you include the OUTPUT_DBPARTNUMS option, all
database partitions must be specified.
A compression dictionary can be built with just one user record. If the loaded data set size is zero
and if there is a preexisting dictionary, the dictionary will not be preserved. The amount of data
required to build a dictionary with this directive is not subject to the policies of ADC. For a
summary, see the following table.
Notes:
1. A compression dictionary can be created for the XML storage object of a table only if the XML
columns are added to the table in Db2 Version 9.7 or later, or if the table is migrated using an
online table move.
2. If a dictionary exists and the compression attribute is enabled, but there are no records to load
into the table partition, a new dictionary cannot be built and the RESETDICTIONARY operation
will not keep the existing dictionary.
RESETDICTIONARYONLY
This option creates a column compression dictionary that is based on the input file, without
loading any rows. You can use this option to create the compression dictionary before you ingest
any data by using SQL-based utilities.
This option is applicable to column-organized tables only.
You cannot specify LOAD REPLACE … RESETDICTIONARYONLY on a subset of database
partitions (SQL27906N). If you include the OUTPUT_DBPARTNUMS option, all database partitions
must be specified.
TERMINATE
One of four modes under which the load utility can execute. Terminates a previously interrupted load
operation, and rolls back the operation to the point in time at which it started, even if consistency
points were passed. The states of any table spaces involved in the operation return to normal, and all
table objects are made consistent (index objects might be marked as invalid, in which case index
• Use one of the hidden column file type modifiers: specify implicitlyhiddeninclude when the
input file contains data for the hidden columns, or implicitlyhiddenmissing when the input
file does not.
• Use the DB2_DMU_DEFAULT registry variable on the server-side to set the default behavior when
data movement utilities encounter tables with implicitly hidden columns. Specify
IMPLICITLYHIDDENINCLUDE when utilities assume that the implicitly hidden columns are
included, or IMPLICITLYHIDDENMISSING when utilities assume that the implicitly hidden columns
are not included.
db2set DB2_DMU_DEFAULT=IMPLICITLYHIDDENINCLUDE
db2 load from delfile1 of del insert into table1
insert-column
Specifies the table column into which the data is to be inserted.
The load utility cannot parse columns whose names contain one or more spaces. For example,
will fail because of the Int 4 column. The solution is to enclose such column names with double
quotation marks:
FOR EXCEPTION table-name
Specifies the exception table into which rows in error are copied. Any row that violates a unique index
or a primary key index is copied. If you specify an unqualified table name, the table name is qualified
with the current schema. The table cannot be a column-organized table.
Information that is written to the exception table is not written to the dump file. In a partitioned
database environment, an exception table must be defined for those database partitions on which the
PART_FILE_LOCATION x
OUTPUT_DBPARTNUMS x
PARTITIONING_DBPARTNUMS x
MODE x
MAX_NUM_PART_AGENTS x
ISOLATE_PART_ERRS x
STATUS_INTERVAL x
PORT_RANGE x
CHECK_TRUNCATION
MAP_FILE_INPUT x
MAP_FILE_OUTPUT x
TRACE x
NEWLINE
DISTFILE x
OMIT_HEADER
RUN_STAT_DBPARTNUM x
Detailed descriptions of these options are provided in "Load configuration options for partitioned
database environments".
RESTARTCOUNT
Deprecated.
USING directory
Deprecated.
For the first row, the XML document is identified by the file named file1.xml. Since the character
delimiter is the double quote character, and double quotation marks exist inside the XDS, the double
quotation marks contained within the XDS are doubled. For the second row, the XML document is
identified by the file named file2.xml, and starts at byte offset 23, and is 45 bytes in length.
LOAD
FROM data.del of DEL INSERT INTO mytable
DECLARE
X1 CURSOR FOR SELECT C1 FROM T1;
Next, the user may issue a LOAD using the cursor type:
LOAD FROM X1 of
CURSOR INSERT INTO T2
Applying the XML specific LOAD options to the cursor type is the same as loading from a file.
Usage notes
• 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 in the following "File type modifiers for the
load utility" section.
• 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.
• If a clustering index exists on the table, the data should be sorted on the clustering index before
loading. Data does not need to be sorted before loading into a multidimensional clustering (MDC) table,
however.
• 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.
• Security labels in their internal format might contain newline characters. If you load 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
LOAD command.
• For performing a load using the CURSOR file type where the DATABASE keyword was specified during
the DECLARE CURSOR statement, the user ID and password used to authenticate against the database
currently connected to (for the load) will be used to authenticate against the source database (specified
by the DATABASE option of the DECLARE CURSOR statement). If no user ID or password was specified
for the connection to the loading database, a user ID and password for the source database must be
specified during the DECLARE CURSOR statement.
• Loading a multiple-part PC/IXF file whose individual parts are copied from a Windows system to an AIX
system is supported. The names of all the files must be specified in the LOAD command. For example,
LOAD FROM DATA.IXF, DATA.002 OF IXF INSERT INTO TABLE1. Loading to the Windows
operating system from logically split PC/IXF files is not supported.
Note:
Notes:
1. The SAVECOUNT option is not allowed when loading XML data, load operations that fail during the load
phase restart from the beginning of the operation.
2. A compression dictionary can be created for the XML storage object of a table only if the XML columns
are added to the table in Db2 Version 9.7 or later, or if the table is migrated using an online table
move.
Table 17. Valid file type modifiers for the load utility: All file formats
Modifier Description
anyorder This modifier specifies that the preservation of the source data order is not
required. Using this modifier yields significant additional performance benefits
on SMP systems. Use this modifier with the cpu_parallelism parameter. If
the value of the cpu_parallelism parameter is 1, this modifier is ignored.
This modifier is not supported if the value of the SAVECOUNT parameter is
greater the 0, because crash recovery after a consistency point requires that
data be loaded in sequence. This modifier is implicitly turned on for all load
operations for column-organized tables, multidimensional clustering (MDC)
tables, and range-partitioned tables.
cdeanalyzefrequency=x x is an integer between 0 - 99 inclusive. This value controls how much data is
sampled in the ANALYZE phase to produce a compression dictionary. In a
massively parallel processing (MPP), the sampling size is not aggregated
across members. The ANALYZE phase is stopped when the first member
reaches max.
generatedignore This modifier informs the load utility that data for all generated columns is
present in the data file but should be ignored. This results in all generated
column values being generated by the utility. This modifier cannot be used
with either the generatedmissing or the generatedoverride modifier.
generatedmissing If this modifier is specified, the utility assumes that the input data file contains
no data for the generated column (not even NULLs). This results in all
generated column values being generated by the utility. This modifier cannot
be used with either the generatedignore or the generatedoverride
modifier.
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:
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 automatically converts the modifier to generatedignore and
proceeds with the load. This has the effect of regenerating all the generated
column values.
This modifier cannot be used with either the generatedmissing or the
generatedignore modifier.
This modifier cannot be used for column-organized tables (SQLSTATE 42858).
Random distribution tables that use the random by generation method have an
internally generated column called the RANDOM_DISTRIBUTION_KEY. This
modifier does not apply to that column, only to other generated columns in the
table. Values for the RANDOM_DISTRIBUTION_KEY will always be
regenerated.
identityignore This modifier informs the load utility that data for the identity column is
present in the data file but should be ignored. This results in all identity values
being generated by the utility. The behavior will be the same for both
GENERATED ALWAYS and GENERATED BY DEFAULT identity columns. This
means that for GENERATED ALWAYS columns, no rows will be rejected. This
modifier cannot be used with either the identitymissing or the
identityoverride modifier.
identitymissing If this modifier is specified, the utility assumes that the input data file contains
no data for the identity column (not even NULLs), and will therefore generate a
value for each row. The behavior will be the same for both GENERATED
ALWAYS and GENERATED BY DEFAULT identity columns. This modifier cannot
be used with either the identityignore or the identityoverride
modifier.
implicitlyhiddenmissin If this modifier is specified, the utility assumes that the input data file does not
g contain data for the implicitly hidden columns and the utility will generate
values for those hidden columns. This modifier cannot be used with the
implicitlyhiddeninclude modifier. See the “Notes” on page 100 section
for information about the precedence when multiple modifiers are specified.
indexfreespace=x x is an integer between 0 and 99 inclusive. The value is interpreted as the
percentage of each index page that is to be left as free space when load
rebuilds the index. Load with INDEXING MODE INCREMENTAL ignores this
option. The first entry in a page is added without restriction; subsequent
entries are added to maintain the percent free space threshold. The default
value is the one used at CREATE INDEX time.
This value takes precedence over the PCTFREE value specified in the CREATE
INDEX statement. The indexfreespace option affects index leaf pages only.
modified by maxanalyzesize=1G
modified by maxanalyzesize=100M
noheader Skips the header verification code (applicable only to load operations into
tables that reside in a single-partition database partition group).
If the default MPP load (mode PARTITION_AND_LOAD) is used against a table
residing in a single-partition database partition group, the file is not expected
to have a header. Thus the noheader modifier is not needed. If the
LOAD_ONLY mode is used, the file is expected to have a header. The only
circumstance in which you should need to use the noheader modifier is if you
wanted to perform LOAD_ONLY operation using a file that does not have a
header.
"CONFIDENTIAL:ALPHA:G2"
"CONFIDENTIAL;SIGMA:G2"
"TOP SECRET:ALPHA:G2"
To load or import this data, the seclabelchar file type modifier must be
used:
"LABEL1"
"LABEL1"
"LABEL2"
To load or import this data, the seclabelname file type modifier must be
used:
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.
Table 18. Valid file type modifiers for the load utility: ASCII file formats (ASC/DEL)
Modifier Description
codepage=x x is an ASCII character string. The value is interpreted as the code page of the
data in the input data set. Converts character data (and numeric data specified
in characters) from this code page to the database code page during the load
operation.
The following rules apply:
• For pure DBCS (graphic), mixed DBCS, and EUC, delimiters are restricted to
the range of x00 to x3F, inclusive.
• For DEL data specified in an EBCDIC code page, the delimiters might not
coincide with the shift-in and shift-out DBCS characters.
• nullindchar must specify symbols included in the standard ASCII set
between code points x20 and x7F, inclusive. This refers to ASCII symbols
and code points. EBCDIC data can use the corresponding symbols, even
though the code points will be different.
This option is not supported in conjunction with the CURSOR filetype.
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. The following section is an example that shows how to
specify a dump file:
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 re-created, but it will be
truncated.
timeformat="x" x is the format of the time in the source file.1 Valid time elements are:
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"
"YYYY/MM/DD HH:MM:SS.UUUUUU"
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:
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. 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 19. 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.
The following rules apply:
• No conversion between data types is performed, with the exception of
BIGINT, INTEGER, and SMALLINT.
• Data lengths must match their target column definitions.
• FLOATs must be in IEEE Floating Point format.
• Binary data in the load source file is assumed to be big-endian, regardless of
the platform on which the load operation is running.
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.
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 modifier cannot be used with the implieddecimal modifier.
reclen=x x is an integer with a maximum value of 32 767. x characters are read for each
row, and a newline 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.
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.
Half-byte sign values can be one of the following value:
modified by chardel""
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.2,
3
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, 3
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:
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:
Table 21. Valid file type modifiers for the load 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 load each row.
Notes
1. Double quotation marks around the date format string are mandatory. Field separators cannot contain
any of the following characters: 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:
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 backslashes, must be preceded by an escape
character (for example, \).
3. "Delimiter considerations for moving data" lists restrictions that apply to the characters that can be
used as delimiter overrides.
4. The load 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 load operation fails, and an error code is returned.
5. When multiple modifiers suffixed with ignore, include, missing, and override are specified, they
are applied in the order that they are listed. In the following statement, data for implicitly hidden
columns that are not identity columns is included in the input data. While data for all identity columns,
regardless of their implicitly hidden status, is not.
However, changing the order of the file type modifiers in the following statement means that data for
all implicitly hidden columns (including hidden identity columns) is included in the input data. While
data for identity columns that are not implicitly hidden is not.
Table 22. LOAD behavior when using code page and usegraphiccodepage
codepage=N usegraphiccodepage LOAD behavior
Absent Absent All data in the file is assumed to be in the database
code page, not the application code page, even if the
CLIENT option is specified.
Present Absent All data in the file is assumed to be in code page N.
Warning: Graphic data will be corrupted when loaded
into the database if N is a single-byte code page.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
• DBADM
Required connection
Database
Command syntax
PRUNE
HISTORY timestamp
WITH FORCE OPTION AND DELETE
Usage notes
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.
Those entries with status DB2HISTORY_STATUS_DO_NOT_DELETE will not be pruned. If the WITH
FORCE OPTION is used, then objects marked as DB2HISTORY_STATUS_DO_NOT_DELETE will still be
pruned or deleted. You can set the status of recovery history file entries to
DB2HISTORY_STATUS_DO_NOT_DELETE using the UPDATE HISTORY command, the ADMIN_CMD with
UPDATE_HISTORY, or the db2HistoryUpdate API. You can use the
DB2HISTORY_STATUS_DO_NOT_DELETE status to prevent key recovery history file entries from being
pruned and to prevent associated recovery objects 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.
Scope
QUIESCE DATABASE results in all objects in the database being in the quiesced mode. Only the allowed
user or group and SYSADM, SYSMAINT, DBADM, or SYSCTRL will be able to access the database or its
objects.
If a database is in the SUSPEND_WRITE state, it cannot be put in quiesced mode.
Authorization
One of the following authorities:
Required connection
Database
Command syntax
QUIESCE DATABASE IMMEDIATE
DB DEFER
WITH TIMEOUT minutes
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 roll back 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, DBADM and SYSCTRL authority will be
able to access to the database or its objects.
Usage notes
• After QUIESCE DATABASE, users with SYSADM, SYSMAINT, SYSCTRL, or DBADM authority, and GRANT
or REVOKE privileges can designate who will be able to connect. This information will be stored
permanently in the database catalog tables.
For example,
• In a Db2 pureScale environment, after quiescing a database and restarting the instance, the database
will remain quiesced across all members. An explicit UNQUIESCE DATABASE command is required to
remove the quiesce state.
• In a Db2 pureScale environment, after quiescing an instance and restarting the instance, the instance
will remain quiesced across all members. An explicit UNQUIESCE INSTANCE command is required to
remove the quiesce state.
Scope
In a single-partition environment, this command quiesces all table spaces involved in a load operation in
exclusive mode for the duration of the load operation. In a partitioned database environment, this
command acts locally on a database partition. It quiesces only that portion of table spaces belonging to
the database partition on which the load operation is performed. For partitioned tables, all of the table
spaces listed in SYSDATAPARTITIONS.TBSPACEID and SYSDATAPARTITIONS.LONG_TBSPACEID
associated with a table and with a status of normal, attached or detached, (for example,
SYSDATAPARTITIONS.STATUS of '"', 'A' or 'D') are quiesced.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
• DBADM
• LOAD
Required connection
Database
Command syntax
QUIESCE TABLESPACES FOR TABLE tablename
schema.tablename
SHARE
INTENT TO UPDATE
EXCLUSIVE
RESET
Command parameters
TABLE
tablename
Specifies the unqualified table name. The table cannot be a system catalog table.
schema.tablename
Specifies the qualified table name. If schema is not provided, the CURRENT SCHEMA will be used.
The table cannot be a system catalog table.
SHARE
Specifies that the quiesce is to be in share mode.
Example
Usage notes
This command is not supported in Db2 pureScale environments.
A quiesce is a persistent lock. Its benefit is that it persists across transaction failures, connection failures,
and even across system failures (such as power failure, or reboot).
A quiesce is owned by a connection. If the connection is lost, the quiesce remains, but it has no owner,
and is called a phantom quiesce. For example, if a power outage caused a load operation to be interrupted
during the delete phase, the table spaces for the loaded table would be left in quiesce exclusive state.
Upon database restart, this quiesce would be an unowned (or phantom) quiesce. The removal of a
phantom quiesce requires a connection with the same user ID used when the quiesce mode was set.
To remove a phantom quiesce:
1. Connect to the database with the same user ID used when the quiesce mode was set.
2. Use the LIST TABLESPACES command to determine which table space is quiesced.
3. Re-quiesce the table space using the current quiesce state. For example:
Once completed, the new connection owns the quiesce, and the load operation can be restarted.
There is a limit of five quiescers on a table space at any given time.
Scope
This command affects all database partitions in the database partition group.
Authorization
One of the following authorities is required:
• SYSADM
• SYSCTRL
• DBADM
In addition, one of the following groups of authorizations is also required:
• DELETE, INSERT, and SELECT privileges on all tables in the database partition group being redistributed
• DELETEIN, INSERTIN, and SELECTIN privileges on the schemas of all tables in the database partition
group being redistributed
• DATAACCESS authority on the schemas of all tables in the database partition group being redistributed
• DATAACCESS authority
Command syntax
REDISTRIBUTE DATABASE PARTITION GROUP db-partition-group
Action
● ● ●
,
ONLY
TABLE ( table-name )
FIRST
● ●
,
EXCLUDE ( table-name )
●
STOP AT local-isotime
Action
CONTINUE
ABORT
Add/Drop DB partition
ADD DBPARTITIONNUM ( n )
DBPARTITIONNUMS TO m
DROP DBPARTITIONNUM ( n )
DBPARTITIONNUMS TO m
PRECHECK ONLY
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.
Note: Tables in the IBMCATGROUP and the IBMTEMPGROUP database partition groups cannot be
redistributed.
NOT ROLLFORWARD RECOVERABLE
When this option is used, the REDISTRIBUTE DATABASE PARTITION GROUP command is not
rollforward recoverable.
• Data is moved in bulk instead of by internal insert and delete operations. This reduces the number
of times that a table must be scanned and accessed, which results in better performance.
• Log records are no longer required for each of the insert and delete operations. This means that you
no longer need to manage large amounts of active log space and log archiving space in your system
when performing data redistribution.
• When using the REDISTRIBUTE DATABASE PARTITION GROUP command with the NOT
ROLLFORWARD RECOVERABLE option, the redistribute operation uses the INDEXING MODE
DEFERRED option for tables that contain XML columns. If a table does not contain an XML column,
the redistribute operation uses the indexing mode specified when issuing the command.
When this option is not used, extensive logging of all row movement is performed such that the
database can be recovered later in the event of any interruptions, errors, or other business need.
10223
1345
112000
0
100
...
In the example, hash partition 2 has a weight of 112000, and partition 3 (with a weight of 0) has no
data mapping to it at all.
The distfilename should contain 32 768 positive integer values in character format. The sum of the
values should be less than or equal to 4 294 967 295.
USING TARGETMAP targetmapfilename
The file specified in targetmapfilename is used as the target distribution map. Data redistribution is
done according to this file.
The targetmapfilename should contain 32 768 integers, each representing a valid database partition
number. The number on any row maps a hash value to a database partition. This means that if row X
contains value Y, then every record with HASHEDVALUE() of X is to be located on database partition Y.
If a database partition, included in the target map, is not in the database partition group, an error is
returned. Issue ALTER DATABASE PARTITION GROUP ADD DBPARTITIONNUM statement before
running REDISTRIBUTE DATABASE PARTITION GROUP command.
If a database partition, excluded from the target map, is in the database partition group, that
database partition will not be included in the partitioning. Such a database partition can be dropped
using ALTER DATABASE PARTITION GROUP DROP DBPARTITIONNUM statement either before or
after the REDISTRIBUTE DATABASE PARTITION GROUP command.
CONTINUE
Continues a previously failed or stopped REDISTRIBUTE DATABASE PARTITION GROUP operation.
If none occurred, an error is returned.
ABORT
Aborts a previously failed or stopped REDISTRIBUTE DATABASE PARTITION GROUP operation. If
none occurred, an error is returned.
ADD
DBPARTITIONNUM n
TO m
Examples
Redistribute database partition group DBPG_1 by providing the current data distribution through a data
distribution file, distfile_for_dbpg_1. Move the data onto two new database partitions, 6 and 7.
Redistribute database partition group DBPG_2 such that:
• The redistribution is not rollforward recoverable;
• Data is uniformly distributed across hash partitions;
• Indexes are rebuilt from scratch;
• Statistics are not collected;
• 180,000 4 KB pages are used as buffered space for transferring the data.
This redistribution operation also quiesces the database and performs a precheck due to the default
values for the QUIESCE DATABASE and PRECHECK command parameters.
Usage notes
• Before starting a redistribute operation, ensure that the tables are in normal state and not in "load
pending" state or "reorg pending" state. Table states can be checked by using the LOAD QUERY
command.
• 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.
• 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 homeinst/sqllib/redist directory on Linux and UNIX operating 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
Compatibilities
Tables containing XML columns that use the Db2 Version 9.5 or earlier XML record format cannot be
redistributed. Use the ADMIN_MOVE_TABLE stored procedure to migrate the table to the new format.
Scope
This command affects all database partitions in the database partition group.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
• DBADM
• SQLADM
• CONTROL privilege on the table.
Required connection
Database
Usage notes
For the full list of usage details, see the REORG TABLE commandREORG TABLE command.
Restrictions:
• For the full list of restrictions, see the REORG TABLE commandREORG TABLE command.
Scope
This command affects all database partitions in the database partition group.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
• DBADM
• SQLADM
• CONTROL privilege on the table.
Required connection
Database
Command syntax
Please see the REORG INDEX/INDEXES command for command syntax details.
Examples
To clean up the pseudo deleted keys and pseudo empty pages in all the indexes on the EMPLOYEE table
while you allow other transactions to read and update the table, enter:
Usage notes
Please see the REORG INDEX/INDEXES command for the full list of usage details.
Authorization
One of the following authorities:
• SYSADM
• SYSMAINT
• SYSCTRL
Required connection
Command syntax
RESET ALERT CONFIGURATION FOR
CONFIG
CFG
DATABASE MANAGER
DB MANAGER
DBM
CONTAINERS
DATABASES
TABLESPACES
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.
DATABASES
Resets 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.
TABLESPACES
Resets default alert settings for all table spaces managed by the database manager to the install
default. 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.
db.sort_privmem_util
If you do not specify this option, all health indicators for the specified object or object type will be
reset.
Scope
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
Required connection
Command syntax
RESET DATABASE CONFIGURATION FOR database-alias
DB CONFIG
CFG
MEMBER member-number
Command parameters
FOR database-alias
Specifies the alias of the database whose configuration is to be reset to the system defaults.
MEMBER member-number
If a database configuration reset is to be applied to a specific member, this parameter may be used. If
this parameter is not provided, the reset will take effect on all members.
Compatibilities
For compatibility with previous versions:
• DBPARTITIONNUM can be substituted for MEMBER, except when the DB2_ENFORCE_MEMBER_SYNTAX
registry variable is set to ON.
Authorization
SYSADM
Required connection
Command syntax
RESET DATABASE MANAGER CONFIGURATION
DB MANAGER CONFIG
DBM CFG
Command parameters
None
Usage notes
This command resets all parameters set by the installation program. This could cause error messages to
be returned when restarting Db2. For example, if the svcename parameter is reset, the user will receive
the SQL5043N error message when trying to restart Db2.
It is not recommended that the svcename parameter, set by the installation program, be modified by the
user.
For more information about these parameters, refer to the summary list of configuration parameters and
the individual parameters.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
Required connection
Command syntax
REWIND TAPE
ON device
Command parameters
ON device
Specifies a valid tape device name. The default value is \\.\TAPE0.
Scope
You can issue the RUNSTATS command from any database partition in the db2nodes.cfg file. You can
use the command 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 by using data from tables on all participating database
partitions.
Required connection
Database
Command syntax
RUNSTATS ON TABLE object-name
UNSET PROFILE
Statistics Options
UTIL_IMPACT_PRIORITY
priority
Statistics Options
ALLOW WRITE ACCESS
Profile Options
SYSTEM
REPEATABLE ( integer-literal )
SYSTEM
Profile Options
SET PROFILE NONE
SET PROFILE
UPDATE ONLY
Index Clause
,
INDEXES index-name
SAMPLED INDEX ALL
DETAILED
UNSAMPLED
Distribution Clause
On Cols Clause
On Cols Clause
ON ALL COLUMNS
,
KEY
ON KEY COLUMNS
Distribution Clause
WITH DISTRIBUTION
On Dist Cols Clause Default Dist Options
ON KEY COLUMNS
Quantile Option
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. This parameter must not
be a table hierarchy. For typed tables, the value of the object-name parameter 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.
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 by using the SET PROFILE options and is
updated by using the UPDATE PROFILE options.
UNSET PROFILE
Removes a statistics profile. For example, the following command removes the profile for the
tablemyschema.mytable table:
FOR INDEXES
Collects and updates statistics for the indexes only. If no table statistics was previously collected on
the table, basic table statistics are also collected. Updates statistics for table cardinality (CARD),
FPAGES, NPAGES, even when table statistics exists. These basic statistics do not include any
distribution statistics. This option cannot be used for views. COLCARD of the leading column of the
index might also be updated.
SAMPLED
Used together only with the DETAILED parameter. Specifying this option does not change the default
functionality from DETAILED. The SAMPLED parameter is left in for compatibility with previous
versions of Db2. This parameter cannot be used for views.
Usage notes
• You should run the RUNSTATS command in the following cases:
– On tables that were modified considerably: For example, if many updates were made, if a significant
amount of data was inserted or deleted, or if you ran the LOAD command without the statistics option
during LOAD.
You can use the following two RUNSTATS commands to achieve the required result:
• If you modified the table since statistics were last collected on the table or its indexes, you must run
RUNSTATS ON TABLE … AND INDEXES ALL. If you use RUNSTATS ON TABLE … FOR INDEXES
ALL, the resulting statistics might be inconsistent.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
Required connection
Command syntax
SET TAPE POSITION TO position
ON device
Command parameters
ON device
Specifies a valid tape device name. The default value is \\.\TAPE0.
TO position
Specifies the mark at which the tape is to be positioned. Db2 for Windows writes a tape mark after
every backup image. A value of 1 specifies the first position, 2 specifies the second position, and so
on. If the tape is positioned at tape mark 1, for example, archive 2 is positioned to be restored.
Scope
UNQUIESCE DB restores user access to all objects in the quiesced database.
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
One of the following authorities:
For database level unquiesce:
• SYSADM
Command syntax
UNQUIESCE DB
Required connection
Database
Command parameters
DB
Unquiesce the database. User access will be restored to all objects in the database.
Usage notes
• In a Db2 pureScale environment, after quiescing a database and restarting the instance, the database
will remain quiesced across all members. An explicit UNQUIESCE DATABASE command is required to
remove the quiesce state.
• In a Db2 pureScale environment, after quiescing an instance and restarting the instance, the instance
will remain quiesced across all members. An explicit UNQUIESCE INSTANCE command is required to
remove the quiesce state.
Authorization
One of the following authorities:
• SYSADM
• SYSMAINT
• SYSCTRL
Required Connection
CONFIG
CFG
DATABASE MANAGER
DB MANAGER
DBM
DATABASES
CONTAINERS
TABLESPACES
DATABASE ON database-alias
TABLESPACE tblspace-name
USING health-indicator-name
ALLALERT
ATTENTION state
,
ALLALERT
ATTENTION state
,
ADD ACTION SCRIPT pathname Add Script Details ON State and User Details
TASK task-name
DB2
STATEMENT TERMINATION CHARACTER character
TERM CHAR
OPERATING SYSTEM
PARMS
ALARM ON hostname
ALLALERT
ATTENTION state
password
db.sort_privmem_util
If it is an operating system script, then the following clause allows one to optionally specify the
command-line parameters, parms, that would be passed to the script upon invocation: COMMAND
LINE PARAMETERS parms
WORKING DIRECTORY pathname
Specifies the absolute path name, pathname, of the directory in which the script will be executed.
USER username USING password
Specifies the user account, username, and associated password, password, under which the script
will be executed.
ADD ACTION TASK name ON [WARNING | ALARM | ALLALERT | ATTENTION state]
Specifies that a new task, called name, is to be added to be run ON the specified condition.
Usage notes
For the ADD ACTION option, the supplied username and password may be exposed in various places
where SQL statement text is captured:
• the network (username/password are passed over the wire unencrypted)
• db2diag log file
• trace files
• dump file
• snapshot monitor (dynamic SQL snapshot)
• system monitor snapshots
• a number of event monitors (statement, deadlock)
• explain tables
• db2pd output (package cache and lock timeout mechanisms, among others)
• Db2 audit records
Authorization
None
Required connection
Command syntax
,
Command parameters
UPDATE CONTACT name
The name of the contact that will be updated.
Authorization
None
Required Connection
Command Syntax
UPDATE CONTACTGROUP name ?
DROP GROUP
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.
Scope
This command updates all database partitions or members by default, except when the following optional
clause is specified:
• MEMBER to update only one database member for a Db2 pureScale environment, or to update only one
database partition in a partitioned database environment.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
Required connection
Command syntax
UPDATE DATABASE CONFIGURATION
CFG
USING
MEMBER member-number
IMMEDIATE
config-keyword value
AUTOMATIC
MANUAL
Command parameters
FOR database-alias
Specifies the alias of the database whose configuration is to be updated. Specifying the database alias
is not required when a database connection has already been established. You can update the
configuration file for another database residing under the same database instance. For example, if you
are connected only to database db11, and issue update db config for alias db22
using .... immediate:
• If there is no active connection on db22, the update will be successful because only the
configuration file needs to be updated. A new connection (which will activate the database) will see
the new change in memory.
• If there are active connections on db22 from other applications, the update will work on disk but
not in memory. You will receive a warning saying that the database needs to be restarted.
MEMBER member-number
The MEMBER clause specifies to which member the change should be applied. Omission of this clause
results in the change being applied to all the members.
Usage notes
For more information about Db2 database 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).
Not all parameters can be updated.
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
aboutwhich parameters are configurable online 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.
Compatibilities
For compatibility with previous versions:
• DBPARTITIONNUM can be substituted for MEMBER, except when the DB2_ENFORCE_MEMBER_SYNTAX
registry variable is set to ON.
Authorization
One of the following:
• SYSADM
• Member of Local Administrator Group on Windows operating system
• Instance Owner on UNIX or Linux operating system
Command syntax
UPDATE DATABASE MANAGER CONFIGURATION
DB MANAGER CONFIG
DBM CFG
USING
MEMBER member-number
config-keyword value
value AUTOMATIC
AUTOMATIC
MANUAL
Command parameters
MEMBER member-number
The MEMBER clause specifies to which member the change should be applied. Omission of this clause
results in the change being applied to all the members.
USING config-keyword value
Specifies the database manager configuration parameter to be updated. For a list of configuration
parameters, refer to the configuration parameters summary. value specifies the value to be assigned
to the parameter.
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.
Note:
MANUAL
Disables automatic tuning for the configuration parameter. The parameter is set to its current internal
value and is no longer updated automatically.
DEFERRED
Make the changes only in the configuration file, so that the changes take effect when the instance is
restarted.
This is a default clause when operating in the CLPPlus interface. DEFERRED need not be called when
using CLPPlus processor.
Usage notes
Not all parameters can be updated.
Some changes to the database manager configuration file become effective only after they are loaded into
memory. For more information aboutwhich 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.
UPDATE HEALTH NOTIFICATION CONTACT LIST command using the ADMIN_CMD procedure
The UPDATE HEALTH NOTIFICATION CONTACT LIST command updates the contact list for
notification about health alerts issued by an instance.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
Required Connection
Command Syntax
UPDATE HEALTH NOTIFICATION CONTACT LIST
NOTIFICATION
DROP GROUP
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.
Authorization
One of the following authorities:
• SYSADM
• SYSCTRL
• SYSMAINT
• DBADM
Command syntax
UPDATE HISTORY FOR object-part WITH
EID eid
COMMENT new-comment
STATUS new-status
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. For history entries, such as backups, that make use of the
sequence number, if the sequence number is not included in the object-part, the default sequence
number 001 will be used. That is, if there are history entries with the same time stamp but different
sequence numbers, and only the time stamp is used as the object-part, the UPDATE HISTORY
command will only update the matching entry with sequence number 001.
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
f
Snapshot backup that was generated by a custom script.
U
User exit
P
Pipe
N
Null device
X
XBSA
Example
The object-part of a backup database history record entry consists of a 14 digit time stamp associated to
the backup image and a 3 digit sequence number of this backup image. To update the database history
record entries for a full database backup taken to 2 target devices on April 13, 1997 at 10:00 a.m., enter:
Usage notes
The primary purpose of the database history records 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.
Authorization
The privileges that are held by the authorization ID of the statement must include at least one of the
following authorities:
Required connection
Database
Command syntax
UPDATE STMM TUNING MEMBER member-number
Command parameter
member-number
The value of member-number is an integer.
In a partitioned database environment:
• If a valid member number is specified, the database server runs the STMM memory tuner on that
member.
• If -1 or a nonexistent member number is specified, the database server selects an appropriate
member on which to run the STMM memory tuner.
In a Db2 pureScale environment:
• If a valid member number is specified, database server runs the STMM memory tuner on that
member.
• If -2 is specified, then the database server enables STMM tuners to run and tune independently on
each member.
• If -1 or a nonexistent member number is specified, the database server selects an appropriate
member on which to run the STMM memory tuner.
Example
In a partitioned database environment, update the user preferred self-tuning memory manager (STMM)
tuning database partition to member 3.
Usage notes
• The STMM tuning process periodically checks for a change in the user preferred STMM tuning member
number value. The STMM tuning process moves to the user preferred STMM tuning member if member-
number exists and is an active member. If the specified STMM tuning member does not exist, the
database server selects an appropriate member. After this command changes the STMM tuning
member number, an immediate change is made to the current STMM tuning member number.
• Command execution status is returned in the SQLCA resulting from the CALL statement.
• This command commits its changes in the ADMIN_CMD procedure.
Compatibilities
For compatibility with previous versions:
• DBPARTITIONNUM can be substituted for MEMBER, except when the DB2_ENFORCE_MEMBER_SYNTAX
registry variable is set to ON.
Authorization
In order for the schema copy to be successful, the user must have the CREATE_SCHEMA privilege as well
as object-specific privileges.
Example: CREATE_TABLE privilege is needed to copy a table and CREATE_INDEX privilege is needed to
copy an index under the ADMIN_COPY_SCHEMA command.
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.
EXECUTE privilege on the ADMIN_COPY_SCHEMA procedure is also needed.
Syntax
ADMIN_COPY_SCHEMA ( sourceschema , targetschema , copymode ,
errortab )
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 before invoking the procedure.
copymode
An input argument of type VARCHAR(128) that specifies the mode of copy operation. Valid options
are:
• 'DDL': create empty copies of all supported objects from the source schema.
• 'COPY': create empty copies of all objects from the source schema, then load each target schema
table with data. Load is done in 'NONRECOVERABLE' mode. A backup must be taken after calling the
ADMIN_COPY_SCHEMA, otherwise the copied tables will be inaccessible following recovery.
• 'COPYNO': create empty copies of all objects from the source schema, then load each target
schema table with data. Load is done in 'COPYNO' mode.
Restrictions
• Only DDL copymode is supported for HADR databases.
• XML with COPY or COPY NO is not supported.
• 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 about how to resolve this
problem, see "Copying a schema".
Usage notes
• References to fully qualified objects within the objects being copied will not be modified. The
ADMIN_COPY_SCHEMA procedure only changes the qualifying schema of the object being created, not
any schema names that appear within SQL expressions for those objects. This includes objects such as
generated columns and trigger bodies.
• This procedure does not support copying the following objects:
– created global temp tables
– index extensions
– nicknames
– packages
– typed tables
– array types
– user-defined structured types (and their transform functions)
– typed views
– jars (Java routine archives)
– staging tables
– aliases with base objects that do not belong to the same source schema
– partitioned tables that require table space mapping
• If one of these objects exists in the schema being copied, the object is not copied but an entry is added
to the error table indicating that the object has not been copied.
• When a replicated table is copied, the new copy of the table does not have subscriptions enabled. The
table is re-created as a basic table only.
Transactional considerations
• If the ADMIN_COPY_SCHEMA procedure is forced to roll back 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.
• 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.
• 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.
Example
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
One of the following authorizations is required:
Example
Return Status = 0
The return status is not zero only when an internal error has been detected (for example, if
SYSTOOLSPACE does not exist).
Errors can be checked by querying the error table:
Usage notes
• If objects in another schema depend on an object being dropped, the default DROP statement
semantics apply.
• This procedure does not support dropping the following objects:
– Index extensions
– Nicknames
– Packages
– Typed tables
– Array types
– User-defined structured types (and their transform functions)
– Typed views
– Jars (Java routine archives)
– Staging tables
– XSR objects
• If one of these objects exists in the schema being dropped, neither the object nor the schema is
dropped, and an entry is added to the error table indicating that the object was not dropped.
• The operation of this procedure requires the existence of the SYSTOOLSPACE table space. This table
space is used to hold metadata used by the ADMIN_DROP_SCHEMA procedure as well as error tables
returned by this procedure. If the table space does not exist, an error is returned.
Syntax
ADMIN_EST_INLINE_LENGTH ( column-name )
Return value
This function returns either an INTEGER value that represents the estimated inline length (in bytes) of the
data, or one of the following values:
NULL
The inputs are NULL.
-1
The data cannot be inlined because there is no valid inline length that would allow the column value
to be inlined.
-2
The estimated inline length of the document cannot be determined because the document was
inserted and stored using an earlier product release.
Function parameters
column-name
Identifies a column of the base table with a data type of XML, BLOB, CLOB, or DBCLOB (SQLSTATE
42884). The column must directly or indirectly reference the column of a base table that is not
generated based on an expression (SQLSTATE 42815).
Example
Example 1: The following example returns the estimated inline length of three XML documents that are
contained in XML column xml_doc1 of TAB1 table.
PK IS_INLINED EST_INLINE_LENGTH
----------- ---------- -----------------
1 1 292
2 0 450
3 0 454
3 record(s) selected.
In the example, the ADMIN_IS_INLINED function indicates that the first document is inlined. Therefore,
the ADMIN_EST_INLINE_LENGTH function returns the actual length of the inlined XML document. The
second document is not inlined, so the ADMIN_EST_INLINE_LENGTH function returns the estimated
inline length that is required to inline the second XML document.
PK IS_INLINED EST_INLINE_LENGTH
----------- ---------- -----------------
2 0 450
1 record(s) selected.
Example 3: The following example returns the estimated inline length of three CLOB data that are
contained in CLOB column clob_1 of the TAB1 table.
PK IS_INLINED EST_INLINE_LENGTH
----------- ---------- -----------------
1 1 68
2 0 3665
3 0 -1
3 record(s) selected.
Usage notes
• XML columns are supported only when the XML documents were inserted using Db2 Version 9.7 or
later. XML documents inserted before this release have a different storage format. When the
ADMIN_EST_INLINE_LENGTH function encounters an incorrect storage format, it returns a value of -2.
• If you plan to increase the column inline length, remember that this length cannot be reduced.
• Increasing the inline length also increases the total row size and might affect the performance of buffer
pools. The total row size has the following limits.
Authorization
The following authorization is required:
• EXECUTE privilege on the routine. EXECUTE privilege on this routine can be granted only by the security
administrator (SECADM).
Syntax
ADMIN_GET_ENCRYPTION_INFO ( )
Information returned
Examples
1. Retrieve the current database encryption settings.
Syntax
ADMIN_GET_INDEX_COMPRESS_INFO ( objecttype , objectschema ,
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Usage notes
• Do not use this function on existing indexes to get actual compression savings; instead run the
RUNSTATS command (if statistics are not up to date), then query either or both of the following catalog
values:
– SYSCAT.INDEXES.PCTPAGESSAVED
– SYSCAT.INDEXPARTITIONS.PCTPAGESSAVED
Example
After database migration, all the existing indexes are uncompressed. You may want to estimate the
potential index compression savings for existing indexes on the table "S.T1", which has a data partition ID
of 3 and resides on database partition number 2. In this example, S is the schema name and T1 is the
table name, and T1 is not compressed
As time passes, you may determine the need to create new indexes for the table and want to estimate
index compression savings for these indexes before compressing them. You may also want to see the
compression statistics from already compressed indexes.
As the first two indexes were already compressed, as indicated by the index_compressed column, the
statement returns values from the system catalogs. In this case, the values from the catalogs were not
collected.
After running RUNSTATS on the table, the next run of the index function yields the corrected results.
Information returned
Syntax
ADMIN_GET_INDEX_INFO ( objecttype , objectschema , objectname )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Additionally, you want to see other index information for all indexes in the schema S2. In this example:
• T2 = a partitioned table with two data partitions
• T3 = a nonpartitioned table
• IND_1 = a nonpartitioned index on T2
• IND_2 = a partitioned index on T2
• IND_3 = a partitioned index on T2
• IND_4 = an index on T3
• IND_5 = an index on T3
Information returned
INDEX_OBJECT_L_SIZE BIGINT Logical size of the index object. For nonpartitioned tables, this
is the amount of disk space logically allocated for all indexes
defined on the table. For a nonpartitioned index on a
partitioned table, this is the amount of disk space logically
allocated for the index. For a partitioned index on a partitioned
table, this is the amount of disk space logically allocated for all
index partitions defined on the data partition. All sizes are
reported in kilobytes (KB).
The logical size is the amount of space that the table or data
partition knows about. It may be less than the amount of
space physically allocated to hold index data for the table or
data partition (for example, in the case of a logical table
truncation). The size returned takes into account full extents
that are logically allocated for the indexes and, for indexes
created in DMS table spaces, an estimate of the EMP extents.
If the table or index is in error when this function is executed,
then this value is NULL.
Syntax
ADMIN_GET_INTRA_PARALLEL ( )
Information returned
This function returns a value of type VARCHAR(3) that specifies the current state of intrapartition
parallelism for the database application. One of the following values is returned:
YES
The database application will run with intrapartition parallelism enabled.
NO
The database application will run with intrapartition parallelism disabled.
Usage notes
The value returned by ADMIN_GET_INTRA_PARALLEL can be different from the state set by
ADMIN_SET_INTRA_PARALLEL in the following cases:
• ADMIN_SET_INTRA_PARALLEL was called during a transaction and the transaction is not yet
committed or rolled back.
• ADMIN_SET_INTRA_PARALLEL was called during a transaction that opens a with hold cursor and the
current transaction has not yet closed the cursor.
• The application is associated with a database workload, which has a value applied to the MAX DEGREE
workload attribute that is different than the one specified by the call to ADMIN_SET_INTRA_PARALLEL.
Example
Find the current state of intrapartition parallelism from CLP:
VALUES SYSPROC.ADMIN_GET_INTRA_PARALLEL
1
---
NO
1 record(s) selected.
Syntax
ADMIN_GET_MEM_USAGE ( )
member
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Examples
Example 1: Report memory usage for all members
4 record(s) selected.
ADMIN_GET_MSGS table function - Retrieve messages generated by a data movement utility that is
executed through the ADMIN_CMD procedure
The ADMIN_GET_MSGS table function is used to retrieve messages generated by a single execution of a
data movement utility command through the ADMIN_CMD procedure.The input parameter operation_id
identifies that operation.
Authorization
EXECUTE privilege on the ADMIN_GET_MSGS table function. The fenced user ID must have read access
to the files under the directory indicated by registry variable DB2_UTIL_MSGPATH. If the registry variable
is not set, then the fenced user ID must have read access to the files in the tmp subdirectory of the
instance directory.
Example
Check all the messages returned by EXPORT utility that was executed through ADMIN_CMD procedure,
with operation ID '24523_THERESAX'
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.
Information returned
Syntax
ADMIN_GET_STORAGE_PATHS ( storage_group_name , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Determine which dropped storage paths are still being used:
STOGROUP STORAGE_PATH
------------------------------ ----------------------------------------
HOTSTORAGE /home/hotel55/hotpath1
1 record(s) selected.
List all the storage paths for the currently connected database:
STOGROUP STORAGE_PATH
------------------------------ ----------------------------------------
IBMSTOGROUP /home/hotel55/instowner
HOTSTORAGE /home/hotel55/hotpath1
COLDSTORAGE /home/hotel55/coldpath1
3 record(s) selected.
Authorization
To execute the routine, one of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
ADMIN_GET_SYSIBM_FUNCTIONS ( routinename , functiontype )
Routine parameters
routinename
An input argument of type VARCHAR(128) that specifies a built-in routine name. Trailing spaces for
the parameter are ignored by the function. The argument must be in upper case.
functiontype
An input argument of type CHAR(1) that specifies the type of the built-in routine. Trailing spaces for
the parameter are ignored by the function. The argument must be in upper case.
If the routinename parameter and the functiontype parameter are both NULL, all the rows are
returned.
Authorization
To execute the routine, one of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
ADMIN_GET_SYSIBM_FUNCTION_PARMS ( routinename , routinespecificname
Routine parameters
routinename
An input argument of type VARCHAR(128) that specifies a built-in routine name. Trailing spaces for
the parameter are ignored by the function. The argument must be in upper case.
Information returned
ADMIN_GET_TAB_COMPRESS_INFO
Syntax
ADMIN_GET_TAB_COMPRESS_INFO ( tabschema , tabname )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Usage notes
• The ADMIN_GET_TAB_COMPRESS_INFO table function is specific to row compression and is not
applicable to column-organized tables. The table function returns 0 rows if you specify a column-
organized table.
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is empty (") or NULL, information is returned for all tables in
the given schema.
• 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.
• If both tabschema and tabname are empty (") or NULL, information is returned for all tables.
• If tabschema or tabname do not exist, or tabname does not correspond to a table name (type T) or a
materialized query table name (type S), an empty result set is returned.
• 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.
• If the specified table has one or more XML columns, the ADMIN_GET_TAB_COMPRESS_INFO table
function will return two rows per partition. One row with OBJECT_TYPE returning 'DATA' and another
row with OBJECT_TYPE returning 'XML'. If the specified table does not have any XML columns, then
only one row per partition will be returned with OBJECT_TYPE of 'DATA'.
Examples
Example 1: View the current compression results and estimate report of both classic row compression
and adaptive compression information of the TABLE1 table in the SCHEMA1 schema.
PCTPAGESSAVED_ADAPTIVE AVGROWSIZE_ADAPTIVE
---------------------- -------------------
70 30
62 198
2 record(s) selected.
ADMIN_GET_TAB_DICTIONARY_INFO
table function - report properties of existing table dictionaries
The ADMIN_GET_TAB_DICTIONARY_INFO table function reports the dictionary information of classic row
compression for a specified schema and table when the table dictionary was created.
This is a direct replacement for the 'REPORT' mode provided by the deprecated
ADMIN_GET_TAB_COMPRESS_INFO table function in previous versions of Db2.
Syntax
ADMIN_GET_TAB_DICTIONARY_INFO ( tabschema , tabname )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Usage notes
• Up to MP4FP4 the table function returns 0 rows if you specify a column-organized table. Since MP4FP4,
ADMIN_GET_TAB_DICTIONARY_INFO table function is also applicable to column-organized tables, but
only OBJECT_TYPE, BUILDER, ROWS_SAMPLED, BUILD_TIMESTAMP, SIZE are filled.
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is empty (") or NULL, information is returned for all tables in
the given schema.
• 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.
• If both tabschema and tabname are empty (") or NULL, information is returned for all tables.
• If tabschema or tabname do not exist, or tabname does not correspond to a table name (type T) or a
materialized query table name (type S), an empty result set is returned.
• If the specified table has one or more XML columns, the ADMIN_GET_TAB_DICTIONARY_INFO table
function will return two rows per partition. One row with OBJECT_TYPE returning 'DATA' and another
row with OBJECT_TYPE returning 'XML'. If the specified table does not have any XML columns, then
only one row per partition will be returned with OBJECT_TYPE of 'DATA'.
• When the ADMIN_GET_TAB_DICTIONARY_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.
Information returned
Examples
Example 1. View a report of the dictionary information of the ADMIN_VIEW table in the PAGECOMP
schema.
1 record(s) selected.
ADMINTABINFO administrative view and ADMIN_GET_TAB_INFO table function - retrieve table size
and state information
The ADMINTABINFO administrative view and the ADMIN_GET_TAB_INFO table function provide methods
to retrieve table size and state information that is not currently available in the catalog views.
Depending on if you are using the administrative view or the table function, refer to one of the following
sections:
• “ADMINTABINFO administrative view” on page 180
• “ADMIN_GET_TAB_INFO table function” on page 181
Authorization
One of the following authorizations is required:
• SELECT privilege on the ADMINTABINFO administrative view
• SELECTIN privilege on the schema of the ADMINTABINFO administrative view
• CONTROL privilege on the ADMINTABINFO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve size and state information for all tables
Example 2: Determine the amount of physical space used by a large number of sparsely populated tables.
Example 3: Identify tables that are eligible to use large RIDs, but are not currently enabled to use large
RIDs.
Example 4: Check the current type of statistics information collected for table T1
1 record(s) selected.
Authorization
EXECUTE privilege on the ADMIN_GET_TAB_INFO table function.
Syntax
ADMIN_GET_TAB_INFO ( tabschema , tabname )
Routine parameters
tabschema
An input argument of type VARCHAR(128) that specifies a schema name.
tabname
An input argument of type VARCHAR(128) that specifies a table name, a materialized query table
name or a hierarchy table name.
Information returned
INDEX_OBJECT_L_SIZE BIGINT Index object logical size. Amount of disk space logically
allocated for the indexes defined on the table, reported
in kilobytes. The logical size is the amount of space that
the table knows about. It might be less than the amount
of space physically allocated to hold index data for the
table (for example, in the case of a logical table
truncation). The size returned takes into account full
extents that are logically allocated for the indexes and,
for indexes created in DMS table spaces, an estimate of
the EMP extents.
For partitioned indexes on partitioned tables, this is the
logical size of the index object containing index
partitions for the data partition identified by
DATA_PARTITION_ID. This value does not take into
account nonpartitioned indexes on partitioned tables.
For information about the both partitioned and
nonpartitioned indexes, you can use the
ADMIN_GET_INDEX_INFO function.
LONG_OBJECT_L_SIZE BIGINT Long object logical size. Amount of disk space logically
allocated for long field data in a table, reported in
kilobytes. The logical size is the amount of space that
the table knows about. It might be less than the amount
of space physically allocated to hold long field data for
the table (for example, in the case of a logical table
truncation). The size returned takes into account full
extents that are logically allocated for long field data
and, for long field data created in DMS table spaces, an
estimate of the EMP extents.
LONG_OBJECT_P_SIZE BIGINT Long object physical size. Amount of disk space
physically allocated for long field data in a table,
reported in kilobytes. The size returned takes into
account full extents allocated for long field data and
includes the EMP extents for long field data created in
DMS table spaces.
LOB_OBJECT_L_SIZE BIGINT LOB object logical size. Amount of disk space logically
allocated for LOB data in a table, reported in kilobytes.
The logical size is the amount of space that the table
knows about. It might be less than the amount of space
physically allocated to hold LOB data for the table (for
example, in the case of a logical table truncation). The
size includes space logically allocated for the LOB
allocation object. The size returned takes into account
full extents that are logically allocated for LOB data and,
for LOB data created in DMS table spaces, an estimate
of the EMP extents.
LOB_OBJECT_P_SIZE BIGINT LOB object physical size. Amount of disk space
physically allocated for LOB data in a table, reported in
kilobytes. The size includes space allocated for the LOB
allocation object. The size returned takes into account
full extents allocated for LOB data and includes the EMP
extents for LOB data created in DMS table spaces.
LOAD_STATUS VARCHAR(12) Current status of a load operation against the table. The
status value can be one of the following values:
• IN_PROGRESS
• NULL (if there is no load in progress for the table and
the table is not in load pending state)
• PENDING
READ_ACCESS_ONLY CHAR(1) 'Y' if the table is in Read Access Only state, 'N'
otherwise. A value of 'N' should not be interpreted as
meaning that the table is fully accessible. If a load is in
progress or pending, a value of 'Y' means the table data
is available for read access, and a value of 'N' means the
table is inaccessible. Similarly, if the table status is set
integrity pending (refer to SYSCAT.TABLES STATUS
column), then a value of 'N' means the table is
inaccessible.
NO_LOAD_RESTART CHAR(1) A value of 'Y' indicates the table is in a partially loaded
state that will not allow a load restart. A value of 'N' is
returned otherwise.
XML_RECORD_TYPE SMALLINT Indicates the type of XML record currently in use for the
table.
• 1 if the type-1 (single node) XML record format is
being used.
• 2 if the type-2 (multi-node) XML record format is
being used.
• Null if the table has no XML columns.
XML_DICTIONARY_SIZE BIGINT Size of the XML dictionary, in bytes, used for data
compression if a data compression dictionary exists for
the XML storage object. If the table does not contain any
XML columns or if a compression dictionary has not
been created, the value is 0.
AMT_STATUS VARCHAR(12) Current status of ADMIN_MOVE_TABLE stored
procedure call against the table. Returns the value
'IN_PROGRESS' or the null value if there is no move in
progress for the table.
Usage notes
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is NULL or the empty string ("), then information is returned
for all tables in the given schema.
• If the tabschema is NULL or the empty string (") and tabname is specified, then an error is returned. To
retrieve information for a specific table, the table must be identified by both schema and table name.
• If both tabschema and tabname are NULL or the empty string ("), then information is returned for all
tables.
• 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.
• When the ADMIN_GET_TAB_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 dropped while information is being retrieved for it). The lock
will only be held for as long as it takes to retrieve the size and state information for the table, not for the
duration of the table function call.
• Physical size reported for tables in SMS table spaces is the same as logical size.
• When an inplace reorg is active on a table, the physical size for the data object (DATA_OBJECT_P_SIZE)
will not be calculated. Only the logical size will be returned. You can tell if an inplace reorg is active on
the table by looking at the INPLACE_REORG_STATUS output column.
Example 2: Suppose there exists a non-partitioned table (DBUSER1.EMPLOYEE), with all associated
objects (for example, indexes and LOBs) stored in a single table space. Calculate how much physical
space the table is using in the table space:
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:
Example 3: Determine the total size for the compression dictionaries for the table DBUSER1.EMPLOYEE.
Example 4: Determine the amount of space reclaimable from a multidimensional clustering table
SAMPLE.STAFF:
SELECT RECLAIMABLE_SPACE
FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO('SAMPLE','STAFF'))
Authorization
One of the following authorizations is required:
• SELECT privilege on the ADMINTEMPCOLUMNS administrative view
• SELECTIN privilege on the schema of the ADMINTEMPCOLUMNS administrative view
Examples
Example 1: Retrieve column attribute information for all instances of created temporary tables and all
declared temporary tables currently existing in the database.
Example 2: Determine which temporary tables active in the database are using the user-defined data type
of USMONEY.
Example 3: Retrieve table schema, table name, and the column names for all declared temporary tables
declared by the SYSTEM_USER.
Syntax
ADMIN_GET_TEMP_COLUMNS ( application_handle , tabschema ,
tabname )
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the ADMIN_GET_TEMP_COLUMNS table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve column information for the declared temporary table TEMPEMPLOYEE for the current
connection.
SELECT *
FROM TABLE (
SYSPROC.ADMIN_GET_TEMP_COLUMNS(
APPLICATION_ID(), 'SESSION', 'TEMPEMPLOYEE'))
AS T
Usage notes
• If both tabschema and tabname are specified, then information is returned for that specific temporary
table only.
• If tabschema is specified but tabname is NULL or the empty string ("), then information is returned for
all tables in the given schema.
• If tabschema is NULL or the empty string (") and tabname is specified, then an error is returned. To
retrieve information for a specific temporary table, the table must be identified by both schema and
table name.
• If both tabschema and tabname are NULL or the empty string ("), then information is returned for all
temporary tables for the connection or all connections, depending on the value of application_handle.
• If tabschema or tabname do not exist, or tabname does not correspond to a temporary table name, or
instances of the identified temporary table do not exist in the database, then an empty result set is
returned.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the ADMINTEMPTABLES administrative view
• SELECTIN privilege on the schema of the ADMINTEMPTABLES administrative view
• CONTROL privilege on the ADMINTEMPTABLES administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
Examples
Example 1: Retrieve table attributes and instantiation time information for all instances of created
temporary tables and declared temporary tables currently existing in the database.
Example 3: Retrieve table attributes and instantiation time information for all declared temporary tables
declared for all the tables instantiated by the user that connected to the database.
Syntax
ADMIN_GET_TEMP_TABLES ( application_handle , tabschema , tabname
Authorization
One of the following authorizations is required:
Examples
Example 1: Retrieve table attributes and instantiation time information for all instances of the created
temporary table DBUSER1.EMPLOYEE for all connections.
Example 2: Retrieve the instantiation time and table space ID for all instances of user temporary tables
for the current connection.
Usage notes
•
• If both tabschema and tabname are specified, then information is returned for that specific temporary
table only.
• If tabschema is specified but tabname is NULL or the empty string ("), then information is returned for
all tables in the given schema.
• If tabschema is NULL or the empty string (") and tabname is specified, then an error is returned. To
retrieve information for a specific temporary table, the table must be identified by both schema and
table name.
• If both tabschema and tabname are NULL or the empty string ("), then information is returned for all
temporary tables for the connection or all connections, depending on the value of application_handle.
• If tabschema or tabname do not exist, or tabname does not correspond to a temporary table name, or
instances of the identified temporary table do not exist in the database, then an empty result set is
returned.
Information returned
Table 38. Information returned for ADMINTEMPTABLES administrative view and ADMIN_GET_TEMP_TABLES
Column name Data type Description
APPLICATION_HANDLE BIGINT application_handle - Application handle monitor
element
APPLICATION_NAME VARCHAR(256) appl_name - Application name monitor element
TABSCHEMA VARCHAR(128) table_schema - Table schema name monitor element
TABNAME VARCHAR(128) table_name - Table name monitor element
INSTANTIATION_TIME TIMESTAMP Time at which the created temporary table instance was
instantiated or the declared temporary table was
declared.
COLCOUNT SMALLINT Number of columns, including inherited columns (if
any).
TAB_FILE_ID BIGINT table_file_id - The file ID (FID) for the table.
TBSP_ID BIGINT tablespace_id - An integer that uniquely represents a
table space used by the current database.
PMAP_ID SMALLINT Identifier for the distribution map that is currently in use
by this table.
PARTITION_MODE CHAR(1) Indicates how data is distributed among database
partitions in a partitioned database system.
• "H" = Hashing
• Blank = No database partitioning
CODEPAGE SMALLINT Code page of the object. This is the default code page
used for all character columns and expression-
generated columns.
ONCOMMIT CHAR(1) Specifies the action taken on this table when a COMMIT
operation is performed.
• "D" = Delete rows
• "P" = Preserve rows
Syntax
ADMIN_IS_INLINED ( column-name )
Return value
This function returns one of the following values of type SMALLINT, or the null value:
1
Indicates that the data is inlined.
0
Indicates that the data is not inlined.
NULL
Indicates that the inputs are NULL.
Function parameters
column-name
Identifies a column of the base table with a data type of XML, BLOB, CLOB, or DBCLOB (SQLSTATE
42884). The column must directly or indirectly reference the column of a base table that is not
generated based on an expression (SQLSTATE 42815).
Example
Example 1: The following example indicates whether the three XML documents in the XML column
xml_doc1 of the TAB1 table are inlined:
PK IS_INLINED
----------- -------------------
1 1
2 0
3 0
3 record(s) selected.
Example 2: The following example indicates whether one of the XML documents in the XML column
xml_doc1 of the TAB1 table is inlined:
PK IS_INLINED
----------- -------------------
1 1
1 record(s) selected.
PK IS_INLINED
----------- -------------------
1 0
2 0
3 1
3 record(s) selected.
Authorization
You must have SQLADM or DBADM authority to invoke the ADMIN_MOVE_TABLE stored procedure. You
must also have the appropriate object creation authorities, including authorities to issue the SELECT
statement on the source table, and to issue the INSERT statement on the target table.
Syntax
There are two equally valid methods to start the ADMIN_MOVE_TABLE stored procedure:
• Use the first method to modify only certain parts of the table definition for the target table. For instance,
if you had a table definition that is quite large (several KB), and all you want to do is modify the table
spaces for the table, you can do so without having to determine the entire CREATE TABLE statement
needed to recreate the source table. All you need to do is to fill out the data_tbsp, index_tbsp, and
lob_tbsp parameters, leaving the other optional parameters blank.
• The second method provides you with more control and flexibility. You can create the target table
beforehand, rather than having the stored procedure create the target table. By creating the target table
beforehand, you can create a target table that would not be possible using the first method.
Method 2:
options , operation )
Procedure parameters
tabschema
This input parameter specifies the name of the schema which contains the table to be moved. This
parameter is case sensitive and has a data type of VARCHAR(128). This parameter can be NULL or the
empty string, if operation REPORT is used to monitor all table moves initiated. For operation
ESTIMATE tabschema can be a LIKE pattern and then ESTIMATE get executed for all matching
tables.
tabname
This input parameter specifies the name of the table to be moved. This parameter is case sensitive
and has a data type of VARCHAR(128). This parameter can be NULL or the empty string, if operation
REPORT is used to monitor all table moves initiated. For operation ESTIMATE tabname can be a LIKE
pattern and then ESTIMATE get executed for all matching tables.
data_tbsp
This input parameter specifies the new data table space for the target table. If a value is provided, the
index_tbsp and lob_tbsp parameters are required. If a value is not provided, the data table space of
the source table is used. This parameter is case sensitive and has a data type of VARCHAR(128). This
parameter can be NULL or the empty string.
index_tbsp
This input parameter specifies the new index table space for the target table. If a value is provided,
the data_tbsp and lob_tbsp parameters are required. If a value is not provided, the index table space
of the source table is used. This parameter is case sensitive and has a data type of VARCHAR(128).
This parameter can be NULL or the empty string.
lob_tbsp
This input parameter specifies the new LOB table space for the target table. If a value is provided, the
data_tbsp and index_tbsp parameters are required. If a value is not provided, the LOB table space of
the source table is used. This parameter is case sensitive and has a data type of VARCHAR(128). This
parameter can be NULL or the empty string.
organize_by_clause
This input parameter can be used to specify an ORGANIZE BY clause for the table. If the value
provided does not begin with 'ORGANIZE BY' then it provides the multi-dimensional clustering (MDC)
specification for the target table. The values are entered as a comma separated list of the columns
used to cluster data in the target table along multiple dimensions. If a value of NULL or "-" is given,
the ORGANIZE BY clause is not used. If an empty string or a single blank is given, the procedure
MESSAGES ON SERVER
NONRECOVERABLE
TO device/directory
LOAD lib-name
OPEN num-sess SESSIONS
If you specify any load options for COPY_USE_LOAD, ADMIN_MOVE_TABLE uses an ADMIN_CMD
load to copy the data from the source table to the target table. If you do not specify any options
for COPY_USE_LOAD, then the NONRECOVERABLE option the db2Load API is used to copy the
data from the source table to the target table.
MESSAGES ON SERVER
Specifies that the message file created on the server by the LOAD command is to be retained
in case of load failures. The WARNINGS entry in the protocol table contain the message
retrieval SQL statement that is required to retrieve all the warnings and error messages that
occur during load, and the message removal SQL statement that is required to clean up the
messages. Note that with or without the clause, the fenced user ID must have the authority to
create files under the directory indicated by the DB2_UTIL_MSGPATH registry variable.
COPY YES
Specifies that a copy of the loaded data will be saved. This option is invalid if forward recovery
is disabled.
Information returned
The key and value pairs that are returned in the result set can be found in Table 40 on page 205. To
modify the user configurable keys in the result set, use the ADMIN_MOVE_TABLE_UTIL stored procedure.
Table 40. Key and value pairs returned by the ADMIN_MOVE_TABLE stored procedure
Key Return Value User Configurable
AGENT_ID Displays the application_handle monitor element No
during the runtime of ADMIN_MOVE_TABLE.
APPLICATION_ID Displays the appl_id monitor element during the No
runtime of ADMIN_MOVE_TABLE.
AUTHID Displays the authorization ID of the user who called No
the stored procedure.
CANCEL_START Displays the CANCEL phase start time. No
CLEANUP_END Displays the CLEANUP phase end time. No
CLEANUP_START Displays the CLEANUP phase start time. No
If operation REPORT is used, monitoring values will be inserted into a Declared Global Temporary Table
(DGTT) named SESSION.ADMIN_MOVE_TABLE.
If operation REPORT is used, the result set is a subset of the DGTT and depends on reporting a single
table move or all table moves initiated.
Result set to monitor a single table move:
• STATUS
• AGENT_ID
• INIT_START
• COPY_THROUGHPUT
• COPY_ECT
• ROWS_STAGING
• REPLAY_THROUGHPUT
• INFLOW_STAGING
• OUTFLOW_STAGING
• GROWTH_STAGING
• REPLAY_ECT
Result set to monitor all table moves initiated:
• TABSCHEMA
• TABNAME
• STATUS
• AGENT_ID
• COPY_ECT
• GROWTH_STAGING
Usage notes
Suggestions for best results when using this procedure
• Avoid making multiple moves into same table space at the same time. This prevents fragmentation
on the target table space.
Restrictions
The following restrictions apply to the ADMIN_MOVE_TABLE stored procedure:
• Only simple tables are supported as the source table. No materialized query tables, typed tables, range
clustered tables, system tables, views, nicknames, or aliases are permitted.
• A table cannot be moved if there is an index with an expression-based key defined on the table.
• A table cannot be moved if an event monitor is currently active on the table.
• Tables without a unique index are subject to a complex and potentially expensive replay phase.
• A generated column cannot be part of the MDC specification.
• Be aware of the large disk space requirements, as the procedure creates two copies of the table and
indexes, plus a staging table and log space.
• Copy performance may be an issue as most of the data is moved to the new table using "insert from
select" form.
• The VERIFY operation for tables without a unique index does not work on tables with LOBs.
• The SYSTOOLSPACE table space must be created and accessible to 'PUBLIC'.
• Lock timeouts are possible during the COPY phase because of long running transactions on the source
table.
• Deadlocks can occur during the SWAP phase.
• Deadlocks can occur on a source table with non-unique indexes and several update processes.
• With VARCHAR2 support enabled, the database treats the empty string and NULL as equivalent values,
but the single blank is a distinct value. With VARCHAR2 support enabled, the organize_by_clause,
partkey_cols, and data_part parameters can use a single blank as distinct from the empty string and
NULL.
• A table cannot be moved if it is in the Set Integrity Pending state.
• A table cannot be moved if there are any XSR objects dependent on it.
• CHECK constraints with three part names are not supported and will return SQL0205. Use only the
column name instead.
Examples
1. This example calls the stored procedure using the first method, where the target table is defined
within the procedure, to move a table named T1 which is located in the schema SVALENTI.
CALL SYSPROC.ADMIN_MOVE_TABLE(
'SVALENTI',
'T1',
'ACCOUNTING',
'ACCOUNT_IDX',
'ACCOUNT_LONG',
'',
'',
'',
'CUSTOMER VARCHAR(80), REGION CHAR(5), YEAR INTEGER, CONTENTS CLOB',
'',
'MOVE')
KEY VALUE
------------------------ -------------------------------------
AUTHID SVALENTI
CLEANUP_END 2009-02-13-11.34.07.609575
CLEANUP_START 2009-02-13-11.34.07.369331
COPY_END 2009-02-13-11.34.05.148018
COPY_OPTS BY_KEY,OVER_INDEX
COPY_START 2009-02-13-11.34.04.841292
COPY_TOTAL_ROWS 100
INDEXNAME T1_INDEX
INDEXSCHEMA SVALENTI
INDEX_CREATION_TOTAL_TIME 0
INIT_END 2009-02-13-11.34.04.552875
INIT_START 2009-02-13-11.34.03.013563
PAR_COLDEF CUSTOMER VARCHAR(80), REGION CHAR(5),
YEAR INTEGER, CONTENTS CLOB
REPLAY_END 2009-02-13-11.34.06.198369
REPLAY_START 2009-02-13-11.34.05.164582
REPLAY_TOTAL_ROWS 100
REPLAY_TOTAL_TIME 5
STATUS COMPLETE
SWAP_END 2009-02-12-11.34.07.214447
SWAP_RETRIES 0
SWAP_START 2009-02-13-11.34.06.244506
VERSION 09.07.0000
22 record(s) selected.
Return Status = 0
2. This example calls the stored procedure using the second method, where the target table is created
outside the procedure and is then named within the target_tabname parameter, to move the same
table as in the previous example.
The first step is to create the table manually:
Then call the stored procedure and pass in the name of the target table:
CALL SYSPROC.ADMIN_MOVE_TABLE(
'SVALENTI',
'T1',
'T1_TARGET',
'',
'MOVE')
Result set 1
------------
KEY VALUE
------------------------ -------------------------------------------
AUTHID SVALENTI
CLEANUP_END 2009-02-13-11.37.49.283090
CLEANUP_START 2009-02-13-11.37.49.125786
COPY_END 2009-02-13-11.37.47.806060
COPY_OPTS BY_KEY,OVER_INDEX
COPY_START 2009-02-13-11.37.47.446616
COPY_TOTAL_ROWS 0
INDEXNAME T1_INDEX
INDEXSCHEMA SVALENTI
INDEX_CREATION_TOTAL_TIME 1
INIT_END 2009-02-13-11.37.47.287703
INIT_START 2009-02-13-11.37.46.052952
PAR_COLDEF using a supplied target table so COLDEF
Return Status = 0
3. In this example, the ADMIN_MOVE_TABLE stored procedure is used to convert the row-organized
STAFF table into a column-organized table. This example specifies the existing STAFF2 table as the
target table.
CALL SYSPROC.ADMIN_MOVE_TABLE(
'OTM01COL',
'STAFF',
'STAFF2',
'COPY_USE_LOAD',
'MOVE'
)
4. In this example, the ADMIN_MOVE_TABLE stored procedure is used to convert the row-organized
STAFF table into a column-organized table without specifying a target table. The ORGANIZE BY
COLUMN clause is specified as a parameter so that the target table is created as a column-organized
table.
CALL SYSPROC.ADMIN_MOVE_TABLE(
'OTM01COL',
'STAFF',
'',
'',
'',
'ORGANIZE BY COLUMN',
'',
'',
'',
'COPY_USE_LOAD',
'MOVE'
)
5. Use the ADMIN_MOVE_TABLE stored procedure to convert the row-organized ACT table into a
column-organized table. The ACT table has been altered to define an enforced foreign key constraint,
as shown in the following example:
Because enforced foreign key (referential integrity) constraints are not supported on column-
organized tables, the NOT_ENFORCED option must be specified so that the target table can be
created as a column-organized table.
CALL ADMIN_MOVE_TABLE(
'TANJINXU',
'ACT',
'',
'',
'',
'ORGANIZE BY COLUMN',
'',
'',
'',
'COPY_USE_LOAD,NOT_ENFORCED',
'MOVE,TRACE'
)
If the status is not COMPLETED, you can call the stored procedure again, specifying the appropriate
option:
• If the status of the procedure is INIT, use the INIT operation, followed by other steps.
• If the status of the procedure is COPY, use the COPY operation, followed by other steps.
• If the status of the procedure is REPLAY, use the REPLAY or SWAP option.
• If the status of the procedure is CLEANUP, use the CLEANUP option.
If the status of an online table move is neither COMPLETED nor CLEANUP, you can call the stored
procedure again, specifying the CANCEL option.
If the status is not COMPLETED and the MOVE operation was specified, CANCEL the operation and
start over, because the MOVE operation runs INIT, COPY, REPLAY, and SWAP operations in one step.
7. Estimate for single table ROW->BLU
ADMIN_MOVE_TABLE is called with operation ESTIMATE. The source table is organized by row. The
target table is organized by column. The estimated size of the target table with a newly created
dictionary is 4739KB. The estimated percent pages saved increased from 61% to 92%. A sample of 1
million rows of the source table where used for the estimation.
call sysproc.admin_move_table('MJUNGFER','ZMJ1','','','','ORGANIZE BY
COLUMN','','','','','ESTIMATE')
Result set 1
--------------
TABSCHEMA TABNAME ROWS_SAMPLED SOURCE_SIZE TARGET_SIZE
SOURCE_PCTPAGESSAVED TARGET_PCTPAGESSAVED
--------- ------- -------------------- -------------------- --------------------
-------------------- --------------------
MJUNGFER ZMJ1 1000000 23104
4739 61 92
1 record(s) selected.
Return Status = 0
1 record(s) selected.
call sysproc.admin_move_table('MJUNGFER','ZMJ1','','','','','','','','','ESTIMATE')
Result set 1
--------------
TABSCHEMA TABNAME ROWS_SAMPLED SOURCE_SIZE TARGET_SIZE
SOURCE_PCTPAGESSAVED TARGET_PCTPAGESSAVED
--------- ------- -------------------- -------------------- --------------------
-------------------- --------------------
1 record(s) selected.
Return Status = 0
1 record(s) selected.
call
sysproc.admin_move_table('MJUNGFER','ZMJ1','','','','','','','','ALLOW_READ_ACCESS','ESTIMAT
E')
Result set 1
--------------
TABSCHEMA TABNAME ROWS_SAMPLED SOURCE_SIZE TARGET_SIZE
SOURCE_PCTPAGESSAVED TARGET_PCTPAGESSAVED
--------- ------- -------------------- -------------------- --------------------
-------------------- --------------------
MJUNGFER ZMJ1 1000000 4216
18269 91 61
1 record(s) selected.
Return Status = 0
1 record(s) selected.
call sysproc.admin_move_table('MJUNGFER','%',' ',' ',' ',' ',' ',' ',' ',' ','ESTIMATE')
call sysproc.admin_move_table('SAPBW1','/BIC/%',' ',' ',' ',' ',' ',' ',' ',' ','ESTIMATE')
Related information
Technical article: Convert row-organized tables to column-organized tables in Db2 with BLU Acceleration
Authorization
One of the following authorizations is required to use the routine:
• EXECUTE privilege on the ADMIN_MOVE_TABLE_UTIL procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, the authorization ID used must be the same as the one used to call the ADMIN_MOVE_TABLE
stored procedure.
Syntax
ADMIN_MOVE_TABLE_UTIL ( tabschema , tabname , action ,
key , value )
Procedure parameters
tabschema
This input parameter specifies the name of the schema containing the table being moved. This name
is case sensitive. and has a data type of VARCHAR(128).
tabname
This input parameter specifies the name of the table being moved. This parameter is case sensitive
and has a data type of VARCHAR(128)
action
This input parameter specifies the action for the procedure to execute.
Valid values are:
• UPSERT: If the specified TABSCHEMA.TABNAME.KEY exists in the ADMIN_MOVE_TABLE protocol
table, this updates the corresponding VALUE with the new value parameter. Otherwise, this inserts
the KEY and VALUE pair into the ADMIN_MOVE_TABLE protocol table.
• DELETE: If the specified TABSCHEMA.TABNAME. KEY exists in the ADMIN_MOVE_TABLE protocol
table, this deletes the specified KEY and VALUE pair from the ADMIN_MOVE_TABLE protocol table.
This parameter has a datatype of VARCHAR(128).
key
This input parameter specifies the key that to "upsert" or delete in the ADMIN_MOVE_TABLE protocol
table.
Usage notes
More information regarding the changeable KEY values in the ADMIN_MOVE_TABLE protocol table is
available in the Usage notes section of the ADMIN_MOVE_TABLE procedure.
Examples
This example covers a basic call to the stored procedure in order to update the compression value and
remove the specific index information used for the target table copying.
First, the ADMIN_MOVE_TABLE procedure is called to start the table move process before calling the
ADMIN_MOVE_TABLE_UTIL procedure in order to update or delete a value in the ADMIN_MOVE_TABLE
protocol table:
CALL SYSPROC.ADMIN_MOVE_TABLE('SVALENTI','T1','','','','','','','','','INIT')
CALL SYSPROC.ADMIN_MOVE_TABLE_UTIL('SVALENTI','T1','UPSERT',
'DEEPCOMPRESSION_SAMPLE','30720')
CALL SYSPROC.ADMIN_MOVE_TABLE_UTIL('SVALENTI','T1','DELETE','COPY_INDEXSCHEMA','')
CALL SYSPROC.ADMIN_MOVE_TABLE_UTIL('SVALENTI','T1','DELETE','COPY_INDEXNAME','')
After these changes, continue the ADMIN_MOVE_TABLE procedure using the new values in the meta
table:
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
EXECUTE privilege on the ADMIN_REMOVE_MSGS procedure. The fenced user ID must be able to delete
files under the directory indicated by registry variable DB2_UTIL_MSGPATH. If the registry variable is not
set, then the fenced user ID must be able to delete the files in the tmp subdirectory of the instance
directory.
Example
Clean up messages with operation ID '24523_THERESAX'.
CALL SYSPROC.ADMIN_REMOVE_MSGS('24523_THERESAX')
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.
Syntax
ADMIN_REVALIDATE_DB_OBJECTS ( object_type , object_schema ,
Procedure parameters
object_type
An input argument of type VARCHAR(30) that identifies the type of the database object. The following
types are valid:
• FUNCTION
• GLOBAL_VARIABLE
• MASK
• METHOD
• MODULE
• PERMISSION
• PROCEDURE
• SPECIFIC
• TABLE
• TRIGGER
• TYPE
• USAGELIST
• VIEW
This value is not case-sensitive. This value can be a null value which means that all of the object types
are considered.
If any of these types is specified, the procedure revalidates all of the invalid objects of that type, with
the exception of those that belong to a MODULE. If you want to revalidate objects that are inside of a
module, use the MODULE type with the name of a specific module, and all of the invalid objects inside
of that module will be revalidated.
If there is a routine that has more than one parameter signature and you only want to revalidate one
of them, use the SPECIFIC type with the name of the routine that you want to revalidate.
If you use the TABLE type, the specified tables will be reorganized and their statistics will be
collected. The procedure invokes the reorg utility, followed by the runstats utility, against regular or
materialized query tables that are in reorg-pending state. The procedure will attempt to use a user
profile for runstats, if one exists. If not, a default runstats operation is invoked.
object_schema
An input argument of type VARCHAR(128) that identifies the schema name used to qualify database
object references. The name is case-sensitive. This value can be NULL.
object_name
An input argument of type VARCHAR(128) that identifies a database object. The name is case-
sensitive. This value cannot be the value of a typed table or a row function, because the procedure
does not support these types of objects; if the name of such an object is specified, an error is
returned. This value can be NULL.
Authorization
One of the following authorities is required:
• EXECUTE privilege on the ADMIN_REVALIDATE_DB_OBJECTS procedure
• SECADM authority when object_type is MASK or PERMISSION
When the value for the force option is 'Y', the invoking user must either be the owner of the object being
revlaidated or hold DBADM authority.
When the value for the debug_flag option is 'Y', the invoking user must be the owner of the object, hold
DBADM authority, or be a member of the SYSDEBUG system defined role.
Examples
Example 1: Revalidate everything in the current database.
CALL SYSPROC.ADMIN_REVALIDATE_DB_OBJECTS()
Example 5: Revalidate all procedures under MY_SCHEMA. In this example, there are three procedures
(proc1, proc2, and proc3) under this schema. The referenced object used by proc1 does not exist. The
following call revalidates proc2 and proc3, but proc1 remains invalid. In this situation, the call returns a
warning.
Example 6: Revalidate an object that does not exist. This example returns an error.
Example 7: Revalidate all procedures under MY_SCHEMA using the named parameter notation.
CALL SYSPROC.ADMIN_REVALIDATE_DB_OBJECTS(
object_type=>'PROCEDURE',object_schema=>'MY_SCHEMA')
Usage notes
All of the non-null parameter values that are passed to the ADMIN_REVALIDATE_DB_OBJECTS procedure
must be satisfied, or the procedure cannot identify the objects that need to be revalidated. For example, if
you specify a view name, but with a trigger type, the procedure does not revalidate the view, because the
type does not match.
This procedure will revalidate only invalid objects and regular or materialized query tables in reorg-
pending state. All invalid objects can be found in SYSCAT.INVALIDOBJECTS. To find out which tables are
in reorg-pending state, use the ADMIN_GET_TAB_INFO table function.
If a valid object is specified as input, the procedure will not perform any operation and returns a success
code. If a failure occurs during the revalidation of tables, the procedure fails. If a failure occurs during the
revalidation of other objects, the procedure ignores the failure and continues revalidating the other
objects. If there is at least one failure, the procedure returns a warning (SQLSTATE 0168B). If the
revalidation of all objects fails, the procedure returns an error (SQLSTATE 429C4). The details of all
revalidation failures of objects except tables can be found in SYSCAT.INVALIDOBJECTS.
In order to revalidate invalid masks or permissions, the user that runs
ADMIN_REVALIDATE_DB_OBJECTS must have SECADM authority. If there is at least one failure, and the
first failure is because the user does not have SECADM authority during revalidation of a mask or
permission, the procedure returns a warning (SQLSTATE 0168B, SQLCODE +361), msg-token2 contains
CREATE PERMISSION or CREATE MASK. If the revalidation of all objects fails, and the first failure is
because the user does not have SECADM authority during revalidation of a mask or permission, the
procedure returns an error (SQLSTATE 42501, SQLCODE -551).
When a global variable is revalidated, it is also instantiated for the current session.
To monitor the progress of a table revalidation, you can monitor the progress of the associated table reorg
operation. For all other objects, query the SYSCAT.INVALIDOBJECTS catalog view; objects are deleted
from this view when they are successfully revalidated, and entries are updated if revalidation fails.
To ensure consistency of catalogs data, the ADMIN_REVALIDATE_DB_OBJECTS routine is designed to run
explicit COMMIT statements. Since the ADMIN_REVALIDATE_DB_OBJECTS routine runs explicit COMMIT
statements, it might not be possible to use a ADMIN_REVALIDATE_DB_OBJECTS routine as a part of a
Syntax
ADMIN_SET_INTRA_PARALLEL ( state )
Procedure parameters
state
An input argument of type VARCHAR(3) that specifies the required state of intrapartition parallelism
for the database application. The argument can be one of the following values:
YES, or yes
The database application starts to run with intrapartition parallelism enabled starting with the
next transaction.
NO, no
The database application starts to run with intrapartition parallelism disabled starting with the
next transaction.
NULL
The database application starts to run with the intrapartition parallelism state dependent on the
value of the intra_parallel database manager configuration parameter, starting with the next
transaction.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: To run the database application with intrapartition parallelism enabled from the next
transaction:
CALL ADMIN_SET_INTRA_PARALLEL('YES')
Example 2: To run the database application with intrapartition parallelism disabled from the next
transaction:
CALL ADMIN_SET_INTRA_PARALLEL('NO')
CALL ADMIN_SET_INTRA_PARALLEL(NULL)
Usage notes
The required state of parallelism set through ADMIN_SET_INTRA_PARALLEL only takes effect for the
application invoking this procedure.
Calls to ADMIN_SET_INTRA_PARALLEL will not change the intra_parallel database manager
configuration parameter setting.
Intrapartition parallelism settings applied by ADMIN_SET_INTRA_PARALLEL can be overridden if the
database application is associated with a workload that has specified a value for the MAX DEGREE
workload attribute.
Intrapartition parallelism cannot be enabled by this procedure if the shared sort heap is not available
(SQL5192W).
ADMINTABINFO administrative view and ADMIN_GET_TAB_INFO table function - retrieve table size
and state information
The ADMINTABINFO administrative view and the ADMIN_GET_TAB_INFO table function provide methods
to retrieve table size and state information that is not currently available in the catalog views.
Depending on if you are using the administrative view or the table function, refer to one of the following
sections:
• “ADMINTABINFO administrative view” on page 230
• “ADMIN_GET_TAB_INFO table function” on page 231
Authorization
One of the following authorizations is required:
• SELECT privilege on the ADMINTABINFO administrative view
• SELECTIN privilege on the schema of the ADMINTABINFO administrative view
• CONTROL privilege on the ADMINTABINFO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve size and state information for all tables
Example 2: Determine the amount of physical space used by a large number of sparsely populated tables.
Example 3: Identify tables that are eligible to use large RIDs, but are not currently enabled to use large
RIDs.
Example 4: Check the current type of statistics information collected for table T1
1 record(s) selected.
Authorization
EXECUTE privilege on the ADMIN_GET_TAB_INFO table function.
Syntax
ADMIN_GET_TAB_INFO ( tabschema , tabname )
Routine parameters
tabschema
An input argument of type VARCHAR(128) that specifies a schema name.
Information returned
DATA_OBJECT_L_SIZE BIGINT Data object logical size. Amount of disk space logically
allocated for the table, reported in kilobytes. The logical
size is the amount of space that the table knows about.
It might be less than the amount of space physically
allocated for the table (for example, in the case of a
logical table truncation). For multidimensional
clustering (MDC) and insert time clustering (ITC) tables,
this size includes the logical size of the block map
object. The size returned takes into account full extents
that are logically allocated for the table and, for objects
created in DMS table spaces, an estimate of the Extent
Map Page (EMP) extents. This size represents the logical
size of the base table only. Space consumed by LOB
data, Long Data, Indexes and XML objects are reported
by other columns.
INDEX_OBJECT_L_SIZE BIGINT Index object logical size. Amount of disk space logically
allocated for the indexes defined on the table, reported
in kilobytes. The logical size is the amount of space that
the table knows about. It might be less than the amount
of space physically allocated to hold index data for the
table (for example, in the case of a logical table
truncation). The size returned takes into account full
extents that are logically allocated for the indexes and,
for indexes created in DMS table spaces, an estimate of
the EMP extents.
For partitioned indexes on partitioned tables, this is the
logical size of the index object containing index
partitions for the data partition identified by
DATA_PARTITION_ID. This value does not take into
account nonpartitioned indexes on partitioned tables.
For information about the both partitioned and
nonpartitioned indexes, you can use the
ADMIN_GET_INDEX_INFO function.
LOAD_STATUS VARCHAR(12) Current status of a load operation against the table. The
status value can be one of the following values:
• IN_PROGRESS
• NULL (if there is no load in progress for the table and
the table is not in load pending state)
• PENDING
READ_ACCESS_ONLY CHAR(1) 'Y' if the table is in Read Access Only state, 'N'
otherwise. A value of 'N' should not be interpreted as
meaning that the table is fully accessible. If a load is in
progress or pending, a value of 'Y' means the table data
is available for read access, and a value of 'N' means the
table is inaccessible. Similarly, if the table status is set
integrity pending (refer to SYSCAT.TABLES STATUS
column), then a value of 'N' means the table is
inaccessible.
NO_LOAD_RESTART CHAR(1) A value of 'Y' indicates the table is in a partially loaded
state that will not allow a load restart. A value of 'N' is
returned otherwise.
NUM_REORG_REC_ALTERS SMALLINT Number of reorg recommend alter operations (for
example, alter operations after which a reorganization is
required) that have been performed against this table
since the last reorganization.
INDEXES_REQUIRE_REBUILD CHAR(1) For nonpartitioned tables, 'Y' if any of the indexes
defined on the table require a rebuild, and 'N' otherwise.
For partitioned tables, 'Y' if any index partitions for the
data partition identified by DATA_PARTITION_ID
require a rebuild, and 'N' otherwise.
XML_RECORD_TYPE SMALLINT Indicates the type of XML record currently in use for the
table.
• 1 if the type-1 (single node) XML record format is
being used.
• 2 if the type-2 (multi-node) XML record format is
being used.
• Null if the table has no XML columns.
XML_DICTIONARY_SIZE BIGINT Size of the XML dictionary, in bytes, used for data
compression if a data compression dictionary exists for
the XML storage object. If the table does not contain any
XML columns or if a compression dictionary has not
been created, the value is 0.
AMT_STATUS VARCHAR(12) Current status of ADMIN_MOVE_TABLE stored
procedure call against the table. Returns the value
'IN_PROGRESS' or the null value if there is no move in
progress for the table.
Usage notes
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is NULL or the empty string ("), then information is returned
for all tables in the given schema.
• If the tabschema is NULL or the empty string (") and tabname is specified, then an error is returned. To
retrieve information for a specific table, the table must be identified by both schema and table name.
• If both tabschema and tabname are NULL or the empty string ("), then information is returned for all
tables.
• 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.
• When the ADMIN_GET_TAB_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 dropped while information is being retrieved for it). The lock
will only be held for as long as it takes to retrieve the size and state information for the table, not for the
duration of the table function call.
• Physical size reported for tables in SMS table spaces is the same as logical size.
• When an inplace reorg is active on a table, the physical size for the data object (DATA_OBJECT_P_SIZE)
will not be calculated. Only the logical size will be returned. You can tell if an inplace reorg is active on
the table by looking at the INPLACE_REORG_STATUS output column.
Example 2: Suppose there exists a non-partitioned table (DBUSER1.EMPLOYEE), with all associated
objects (for example, indexes and LOBs) stored in a single table space. Calculate how much physical
space the table is using in the table space:
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:
Example 3: Determine the total size for the compression dictionaries for the table DBUSER1.EMPLOYEE.
Example 4: Determine the amount of space reclaimable from a multidimensional clustering table
SAMPLE.STAFF:
SELECT RECLAIMABLE_SPACE
FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO('SAMPLE','STAFF'))
Authorization
One of the following authorizations is required:
• SELECT privilege on the ADMINTEMPCOLUMNS administrative view
• SELECTIN privilege on the schema of the ADMINTEMPCOLUMNS administrative view
Examples
Example 1: Retrieve column attribute information for all instances of created temporary tables and all
declared temporary tables currently existing in the database.
Example 2: Determine which temporary tables active in the database are using the user-defined data type
of USMONEY.
Example 3: Retrieve table schema, table name, and the column names for all declared temporary tables
declared by the SYSTEM_USER.
Syntax
ADMIN_GET_TEMP_COLUMNS ( application_handle , tabschema ,
tabname )
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the ADMIN_GET_TEMP_COLUMNS table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve column information for the declared temporary table TEMPEMPLOYEE for the current
connection.
SELECT *
FROM TABLE (
SYSPROC.ADMIN_GET_TEMP_COLUMNS(
APPLICATION_ID(), 'SESSION', 'TEMPEMPLOYEE'))
AS T
Usage notes
• If both tabschema and tabname are specified, then information is returned for that specific temporary
table only.
• If tabschema is specified but tabname is NULL or the empty string ("), then information is returned for
all tables in the given schema.
• If tabschema is NULL or the empty string (") and tabname is specified, then an error is returned. To
retrieve information for a specific temporary table, the table must be identified by both schema and
table name.
• If both tabschema and tabname are NULL or the empty string ("), then information is returned for all
temporary tables for the connection or all connections, depending on the value of application_handle.
• If tabschema or tabname do not exist, or tabname does not correspond to a temporary table name, or
instances of the identified temporary table do not exist in the database, then an empty result set is
returned.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the ADMINTEMPTABLES administrative view
• SELECTIN privilege on the schema of the ADMINTEMPTABLES administrative view
• CONTROL privilege on the ADMINTEMPTABLES administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
Examples
Example 1: Retrieve table attributes and instantiation time information for all instances of created
temporary tables and declared temporary tables currently existing in the database.
Example 3: Retrieve table attributes and instantiation time information for all declared temporary tables
declared for all the tables instantiated by the user that connected to the database.
Syntax
ADMIN_GET_TEMP_TABLES ( application_handle , tabschema , tabname
Authorization
One of the following authorizations is required:
Examples
Example 1: Retrieve table attributes and instantiation time information for all instances of the created
temporary table DBUSER1.EMPLOYEE for all connections.
Example 2: Retrieve the instantiation time and table space ID for all instances of user temporary tables
for the current connection.
Usage notes
•
• If both tabschema and tabname are specified, then information is returned for that specific temporary
table only.
• If tabschema is specified but tabname is NULL or the empty string ("), then information is returned for
all tables in the given schema.
• If tabschema is NULL or the empty string (") and tabname is specified, then an error is returned. To
retrieve information for a specific temporary table, the table must be identified by both schema and
table name.
• If both tabschema and tabname are NULL or the empty string ("), then information is returned for all
temporary tables for the connection or all connections, depending on the value of application_handle.
• If tabschema or tabname do not exist, or tabname does not correspond to a temporary table name, or
instances of the identified temporary table do not exist in the database, then an empty result set is
returned.
Information returned
Table 45. Information returned for ADMINTEMPTABLES administrative view and ADMIN_GET_TEMP_TABLES
Column name Data type Description
APPLICATION_HANDLE BIGINT application_handle - Application handle monitor
element
APPLICATION_NAME VARCHAR(256) appl_name - Application name monitor element
TABSCHEMA VARCHAR(128) table_schema - Table schema name monitor element
TABNAME VARCHAR(128) table_name - Table name monitor element
INSTANTIATION_TIME TIMESTAMP Time at which the created temporary table instance was
instantiated or the declared temporary table was
declared.
COLCOUNT SMALLINT Number of columns, including inherited columns (if
any).
TAB_FILE_ID BIGINT table_file_id - The file ID (FID) for the table.
TBSP_ID BIGINT tablespace_id - An integer that uniquely represents a
table space used by the current database.
PMAP_ID SMALLINT Identifier for the distribution map that is currently in use
by this table.
PARTITION_MODE CHAR(1) Indicates how data is distributed among database
partitions in a partitioned database system.
• "H" = Hashing
• Blank = No database partitioning
CODEPAGE SMALLINT Code page of the object. This is the default code page
used for all character columns and expression-
generated columns.
ONCOMMIT CHAR(1) Specifies the action taken on this table when a COMMIT
operation is performed.
• "D" = Delete rows
• "P" = Preserve rows
Syntax
ADMIN_TASK_ADD ( name , begin_timestamp , end_timestamp ,
Procedure parameters
name
An input argument of type VARCHAR(128) that specifies the name of the task. This argument cannot
be NULL.
begin_timestamp
An input argument of type TIMESTAMP that specifies the earliest time a task can begin execution. The
value of this argument cannot be in the past, and it cannot be later than end_timestamp.
When task execution begins depends on how this argument and the schedule argument are defined:
• If the begin_timestamp argument is not NULL:
– If the schedule argument is NULL, the task execution begins at begin_timestamp.
– If the schedule argument is not NULL, the task execution begins at the next scheduled time at or
after begin_timestamp.
• If the begin_timestamp argument is NULL:
– If the schedule argument is NULL, the task execution begins immediately.
– If the schedule argument is not NULL, the task execution begins at the next scheduled time.
end_timestamp
An input argument of type TIMESTAMP that specifies the last time that a task can begin execution.
The value of this argument cannot be in the past, and it cannot be earlier than begin_timestamp. If the
argument is NULL, the task can continue to execute as scheduled indefinitely.
An executing task will not be interrupted at its end_timestamp.
max_invocations
An input argument of type INTEGER that specifies the maximum number of executions allowed for the
task. If the argument is NULL, there is no limit to the number of times the task can execute. If the
argument is 0, the task will not execute.
This value applies to the schedule if schedule is not NULL.
If both end_timestamp and max_invocations are specified, end_timestamp takes precedence. That is,
if the end_timestamp timestamp is reached, even though the number of task executions so far has not
reached the value of max_invocations, the task will not be executed again.
schedule
An input argument of type VARCHAR(1024) that specifies a task execution schedule at fixed points in
time. If the argument is NULL, the task is not scheduled at fixed points in time.
The schedule string must be specified using the UNIX cron format.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Usage notes
The SYSTOOLSPACE table space must exist before you call the ADMIN_TASK_ADD procedure. If it does
not exist, the procedure will return an SQL0204N error message.
When a task is scheduled, the authorization ID of the current session user is recorded. The scheduler
switches to this session authorization ID when the executing the task.
The administrative task scheduler does not support the execution of procedures that perform a database
connection without a specified user ID and password. For example, the ADMIN_CMD procedure can be
Example
Example 1: Create a task that performs an online TSM backup daily at 12:00 AM, with immediate effect:
CALL SYSPROC.ADMIN_TASK_ADD
( 'DAILY TSM BACKUP',
CURRENT_TIMESTAMP,
NULL,
NULL,
'0 0 * * *',
'SYSPROC',
'ADMIN_CMD',
'VALUES(''BACKUP DATABASE SALES ONLINE USE TSM WITHOUT PROMPTING'')',
NULL,
NULL )
CALL SYSPROC.ADMIN_TASK_ADD
('FLUSH EVENT MONITOR EVERY HOUR',
NULL,
NULL,
NULL,
'0 0-23 * * *',
'PROD',
'FLUSH_EVENT_MONITOR',
NULL,
NULL,
NULL )
Table 46. Field names and values for the UNIX cron format
Field name Allowed values
minute 0-59
hour 0-23
day of month 1-31
month • 1-12, where 1 is January, 2 is February, and so
on.
• Uppercase, lowercase and mixed-case three
character strings, based on the English name of
the month. For example: jan, feb, mar, apr,
may, jun, jul, aug, sep, oct, nov, or dec.
1,2,5,9
0-4,8-12
Step values
Step values can be used in conjunction with ranges. The syntax range/step defines the range and an
execution interval.
If you specify first-last/step, execution takes place at first, then at all successive values that are
distant from first by step, until last.
For example, to specify command execution every other hour, use 0-23/2. This expression is equivalent
to the value 0,2,4,6,8,10,12,14,16,18,20,22.
If you specify */step, execution takes place at every interval of step through the unrestricted range. For
example, as an alternative to 0-23/2 for execution every other hour, use */2.
Example
Table 2 lists values that you can use for the schedule argument in ADMIN_TASK_ADD or
ADMIN_TASK_UPDATE procedures for various scheduling scenarios.
Table 47. Example task schedules and the appropriate schedule argument values
Desired task schedule schedule value
2:10 PM every Monday 10 14 * * 1
Every day at midnight 0 0 * * *
Every weekday at midnight 0 0 * * 1-5
Midnight on 1st and 15th day of the month 0 0 1,15 * *
6.32 PM on the 17th, 21st and 29th of November 32 18 17,21,29 11 mon,wed
plus each Monday and Wednesday in November
each year
Authorization
SELECT or CONTROL privilege on the ADMIN_TASK_LIST administrative view. Unless the database was
created with the RESTRICTIVE option, SELECT privilege is granted to PUBLIC by default.
When you query the ADMIN_TASK_LIST view, it will only return the tasks that were created using your
session authorization ID. If you have SYSADM, SYSCTRL, SYSMAINT, or DBADM authority, all tasks are
returned.
Information returned
Note:
Syntax
ADMIN_TASK_REMOVE ( name , end_timestamp )
Procedure parameters
name
An input argument of type VARCHAR(128) that specifies the name of the task.
end_timestamp
An output argument of type TIMESTAMP that specifies the status record end_timestamp timestamp.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the ADMIN_TASK_REMOVE procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Although the statement authorization ID might allow the procedure to be executed, successful removal of
task and status records depends on the value of the current session authorization ID. The current session
authorization ID must match the session authorization ID that was recorded when the task was created.
Users with SYSADM, SYSCTRL, SYSMAINT, or DBADM authority can remove any task or status record. If
an unauthorized user attempts to remove a task or status record, an SQL0551N is returned.
Usage notes
The task is not removed until the unit of work is committed.
The behavior of the task removal depends on how the name and end_timestamp arguments are defined:
• If the end_timestamp argument is NULL:
– If the name argument is NULL, all tasks and status records are removed. If one or more tasks are
currently running, then the task and associated status records are not removed. In this case,
SQL1464W is returned.
– If the name argument is not NULL, the task record that matches name is removed. If the specified
task is currently running, the task is not removed and SQL20453N is returned. If the specified task is
removed, all associated status records are removed.
• If the end_timestamp argument is not NULL:
– If the name argument is NULL, all status records with end_timestamp timestamps less than or equal
to end_timestamp are removed. No task records are removed. The procedure will not remove any
status records that have a status value of RUNNING.
Example
Remove a backup task called 'DAILY TSM BACKUP':
Authorization
SELECT or CONTROL privilege on the ADMIN_TASK_STATUS administrative view. Unless the database
was created with the RESTRICTIVE option, SELECT privilege is granted to PUBLIC by default.
When you query the ADMIN_TASK_STATUS view, it will only return the task status records that were
created by your session authorization ID.
Examples
Example 1: Request the status of tasks in the scheduler:
Example 2: Format the data in the SQLERRMC column using the SQLERRM function:
Information returned
SQLSTATE CHAR(5) If the STATUS is COMPLETED, this value indicates the SQLSTATE
returned by the CALL to the procedure.
If the STATUS is NOTRUN, this value indicates the SQLSTATE of the
error that prevented the task from running.
If the status is RUNNING or UNKNOWN, this value will be NULL.
SQLERRMC VARCHAR(70) Contains one or more tokens, separated by X'FF', as they appear in the
FOR BIT DATA SQLERRMC field of the SQLCA. These tokens are substituted for
variables in the descriptions of error conditions
If the STATUS is COMPLETED, this value indicates the SQLERRMC
returned by the CALL to the procedure.
If the STATUS is NOTRUN, this value indicates the SQLERRMC of the
error that prevented the task from running.
If the status is RUNNING or UNKNOWN, this value will be NULL.
• 1 The BEGIN_TIME and END_TIME are based on the database server's time zone. The user is
responsible for making adjustments for daylight savings time (DST).
Syntax
ADMIN_TASK_UPDATE ( name , begin_timestamp , end_timestamp ,
Procedure parameters
name
An input argument of type VARCHAR(128) that specifies the name of an existing task. This argument
cannot be NULL.
begin_timestamp
An input argument of type TIMESTAMP that specifies the earliest time a task can begin execution. The
value of this argument cannot be in the past, and it cannot be later than end_timestamp.
When task execution begins depends on how this parameter and the schedule parameter are defined:
• If the begin_timestamp argument is not NULL:
– If the schedule argument is NULL, the task execution begins at begin_timestamp.
– If the schedule argument is not NULL, the task execution begins at the next scheduled time at or
after begin_timestamp.
• If the begin_timestamp argument is NULL:
– If the schedule argument is NULL, the task execution begins immediately.
– If the schedule argument is not NULL, the task execution begins at the next scheduled time.
end_timestamp
An input argument of type TIMESTAMP that specifies the last time that a task can begin execution.
The value of this argument cannot be in the past, and it cannot be earlier than begin_timestamp. If the
argument is NULL, the task can continue to execute as scheduled indefinitely.
An executing task will not be interrupted at its end_timestamp.
max_invocations
An input argument of type INTEGER that specifies the maximum number of executions allowed for the
task. If the argument is NULL, there is no limit to the number of times the task can execute. If the
argument is 0, the task will not execute.
This value applies to the schedule if schedule is not NULL.
If both end_timestamp and max_invocations are specified, end_timestamp takes precedence. That is,
if the end_timestamp timestamp is reached, even though the number of task executions so far has not
reached the value of max_invocations, the task will not be executed again.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the ADMIN_TASK_UPDATE procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Although the statement authorization ID might allow the procedure to be executed, a task cannot be
updated unless the current session authorization ID matches the session authorization ID that was
recorded when the task was created. Users with SYSADM, SYSCTRL, SYSMAINT, or DBADM can update
any existing task. Attempting to update a task that was added by a different user returns SQL0551N.
Usage notes
If invalid arguments are passed into the procedure, SQL0171N will be returned. The tokens of the
message will indicate which argument is invalid and the name of the procedure.
Changes to the task do not take effect until the unit of work is committed and the scheduler has fetched
the updated task definition. Leaving the unit of work uncommitted may delay or prevent the execution of
the existing task.
The scheduler checks for updated tasks every 5 minutes. To ensure the task executes as expected, the
earliest begin time, as defined by the begin_timestamp, end_timestamp and schedule parameters, should
be at least 5 minutes after the unit of work commits.
The database must be active on all database partitions to ensure the task can be executed by the
scheduler.
The begin_timestamp, end_timestamp, and schedule are based on the database server's time zone.
Special attention is required when scheduling a task during the transition period of daylight savings time
(DST). If the task is scheduled to run 2:01 AM and it is the time of year when the time springs forward, the
task will not run as the clock skips from 2:00 AM to 3:00 AM. If the DST change occurs when the database
is activated and there is no task scheduled during the DST change time, the first scheduled task after the
DST change will not run. Tasks will run normally from the second task onwards. For example, if no task is
scheduled between 2:00 AM to 3:00 AM but there is a task at 3:10 AM which is also the first task after
DST change, this task will not run. This is independent of the time after the DST change in which the task
is scheduled. For example, whether the first task after DST is scheduled one day or one month after the
DST change, the task will not run as long as it is the first task after DST change and the database is kept
active the entire time. On the other hand, when the time falls back an hour, tasks that were originally
Syntax
AUDIT_ARCHIVE ( directory , member )
Authorization
Execute privilege on the AUDIT_ARCHIVE procedure or table function.
Examples
Example 1: Archive the audit log(s) for all members to the default directory using the procedure.
Example 2: Archive the audit log(s) for all members to the default directory using the table function.
Table 50. Information returned by the AUDIT_ARCHIVE procedure and table function
Column name Data type Description
DBPARTITIONNUM SMALLINT dbpartitionnum - Database partition number monitor
element
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) FOR The sqlerrmc received while attempting archive file.
BIT DATA If SQLSTATE is NULL, the value is zero.
MEMBER SMALLINT member - Database member monitor element
Syntax
AUDIT_DELIM_EXTRACT ( delimiter , target_directory , source_directory
, 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.
target_directory
An optional input argument of type VARCHAR(1024) that specifies the directory where the delimited
files will be stored. If the argument is null or an empty string, same directory as the source_directory
will be used
source_directory
An optional input argument of type VARCHAR(1024) that specifies the directory where the archived
audit log files are stored. If the argument is null or an empty string, the audit default will be used.
file_mask
An optional input argument of type VARCHAR(1024) is a mask for which files to extract. If the
argument is null or an empty string, it will extract from all audit log files in the source directory. If the
archived logs are in the same folder as the active log, setting the parameter to null results in trying to
extract from all the logs including the active log. To avoid errors, use the following instead to extract
all archived logs:
('%.log.%.%')
Authorization
Execute privilege on the AUDIT_DELIM_EXTRACT function.
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.
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.
Authorization
EXECUTE privilege on AUDIT_LIST_LOGS table function.
Examples
Example 1: Lists all archived audit logs in the default audit archive directory:
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>
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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 argment can be one of the following values:
AUTO_BACKUP
automatic backup
AUTO_REORG
automatic table and index reorganization
AUTO_RUNSTATS
automatic table runstats operations
MAINTENANCE_WINDOW
maintenance window
Example
Here is an example of a call to the AUTOMAINT_GET_POLICY procedure from within embedded SQL C
source code.
• A BLOB variable is declared for the procedure output parameter.
• The procedure is called, specifying automated backup as the type of automatic maintenance policy, and
specifying the BLOB variable as the output parameter in which the procedure will return the backup
policy for the currently connected database.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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 argument can be one of the following values:
AUTO_BACKUP
automatic backup
AUTO_REORG
automatic table and index reorganization
AUTO_RUNSTATS
automatic table runstats operations
Example
To get the current automatic maintenance settings for backup operations:
This will create an XML file named AutoBackup.xml in the tmp subdirectory under the database
instance directory.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
Syntax
AUTOMAINT_SET_POLICY ( policy_type , policy )
Procedure parameters
policy_type
An input argument of type VARCHAR(128) that specifies the type of automatic maintenance policy to
configure. The value can be one of:
AUTO_BACKUP
automatic backup
AUTO_REORG
automatic table and index reorganization
AUTO_RUNSTATS
automatic table runstats operations
MAINTENANCE_WINDOW
maintenance window
policy
An input argument of type BLOB(2M) that specifies the automatic maintenance policy in XML format.
See the sample XML files in the SQLLIB/samples/automaintcfg directory for full details about
each element and attribute that can be specified.
Examples
Example 1: To set the current automatic maintenance settings for runstats operations:
CALL SYSPROC.AUTOMAINT_SET_POLICY
( 'AUTO_RUNSTATS',
BLOB(' <?xml version=\"1.0\" encoding=\"UTF-8\"?>
<DB2AutoRunstatsPolicy
xmlns=\"http://www.ibm.com/xmlns/prod/db2/autonomic/config\">
<RunstatsTableScope><FilterCondition/></RunstatsTableScope>
</DB2AutoRunstatsPolicy>')
)
This replaces 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."
Example 2: The automatic reorganization feature can use the new "RECLAIM EXTENTS" option to
reorganize multidimensional clustering (MDC) or insert time clustering (ITC) tables. To enable this
feature, set the "reclaimExtentSizeForTables" value in the AUTO_REORG policy:
CALL SYSPROC.AUTOMAINT_SET_POLICY
('AUTO_REORG',
BLOB(' <?xml version=\"1.0\" encoding=\"UTF-8\"?>
<DB2AutoReorgPolicy
xmlns=\"http://www.ibm.com/xmlns/prod/db2/autonomic/config\">
<ReorgOptions dictionaryOption="Keep" indexReorgMode="Online"
useSystemTempTableSpace="false" reclaimExtentSizeForTables ="1024" >
<ReorgTableScope>
<FilterClause>TABSCHEMA NOT LIKE 'EMP%'</FilterClause>
</ReorgTableScope>
There are sample XML input files located in the SQLLIB/samples/automaintcfg directory that you
can modify to suit your requirements and then pass the XML content in through the BLOB() scalar function
as in the example.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
AUTOMAINT_SET_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
configure. The argument can be one of the following values:
AUTO_BACKUP
automatic backup
AUTO_REORG
automatic table and index reorganization
AUTO_RUNSTATS
automatic table runstats operations
MAINTENANCE_WINDOW
maintenance window
policy_file_name
An input argument of type VARCHAR(2048) that specifies the name of the file that is available in the
tmp subdirectory of the database instance directory.
Note: When the file name is specified with a relative path, the correct path separator for the database
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'
Example
To modify the current automatic maintenance settings for automatic backup:
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 database instance
directory.
There are sample XML input files located in the SQLLIB/samples/automaintcfg directory which can
be used as reference to create policy xml files.
Table 52. Common SQL API shared input and output parameters
Parameter Description
major_version Indicates the document type major version that the
caller supports for the XML documents passed as
parameters in the procedure.
minor_version Indicates the document type minor version that
the caller supports for the XML documents passed
as parameters in the procedure.
The parameters major_version and minor_version
are used together to ensure that the caller does
not use an XML input document of an incorrect
version. The procedure processes all XML
documents in the specified major_version and
minor_version, or returns an error if a version is not
valid. This design supports extensibility in future
releases because newer document type versions
can be added without affecting existing
applications.
When you call the procedure, you specify the major version and minor version of the XML document that
you want to return. The contents of the XML output document will vary depending on the values that you
specify.
For example, the GET_CONFIG procedure retrieves the database and database manager configuration
parameters that are set for a particular instance. When this procedure is called with major_version 2 and
minor_version 0, it returns an XML document that contains configuration parameters grouped into
categories. However, when the same procedure is called with major_version 1 and minor_version 0, it
returns an XML document that contains configuration parameters, but they are not grouped into
categories.
Likewise, the GET_MESSAGE procedure retrieves the message text and SQLSTATE for a specified
SQLCODE. When this procedure is called with major_version 2 and minor_version 0, it returns an XML
document that contains the short text message, long text message, and SQLSTATE for the corresponding
SQLCODE. However, when the same procedure is called with major_version 1 and minor_version 0, it
Important: XML input documents must be encoded in UTF-8 and contain English characters only.
To run a procedure in complete mode, specify "true" for the Complete key in the input XML document,
and pass the following minimal content:
Any XML elements that are not required are ignored and are not returned in the output document.
When you run the procedure, a complete XML input document is returned in the xml_output parameter of
the stored procedure. The returned XML document includes a document type and a section for all
possible required parameters and optional parameters. The returned XML document also includes other
entries (such as display names, hints, and the document locale) that are not required, but are typically
needed when rendering the document in a client application.
After rendering the XML document and modifying it in a platform-independent way, you can run the same
stored procedure and pass in the modified XML document as input.
Entries in the XML output document might be grouped using nested dictionaries. Each entry in the XML
output document describes a single piece of information. The entry consists of the value, the display
name, and a hint. Optionally, a display unit might be provided. Display name, hint, and display unit are
language-sensitive and will be translated to the language specified in the value for the requested_locale
parameter (or the default if the requested locale is not yet supported). In general, an entry has a structure
similar to the following example:
IBM data servers have a common parameter document that includes some keywords that are applicable
to all data servers, and others that are data server specific. Whenever a data server adds or removes a
new keyword, the version number (for all data servers) is incremented. Depending on the change, the
major version number might be increased and the minor version number set to 0 (zero), or only the minor
version number might be incremented.
XML output documents are generated in UTF-8 and contain English characters only.
Example
The following XPath expression selects the value for the Data Server Product Version key from an XML
output document:
The procedure returns the string 8.1.0.356 in the xml_output parameter. Therefore, the procedure call
returns a single value rather than an XML document.
XML message documents are generated in UTF-8 and contain English characters only.
Example
In the following example, a call to the GET_MESSAGE procedure results in an SQL warning:
The value for the Short Message Text key provides additional information about the warning.
Syntax
CANCEL_WORK ( major_version , minor_version , requested_locale ,
Procedure parameters
major_version
An input and output argument of type INTEGER that indicates the major document version. On input,
this argument indicates the major document version that the caller supports for the XML documents
passed as parameters in the procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error (+20458) if the version is not valid. On output, this parameter specifies the highest major
document version that is supported by the procedure. To determine the highest supported document
version, specify NULL for this input parameter and all other required parameters.
Supported versions: 1
minor_version
An input and output argument of type INTEGER that indicates the minor document version. On input,
this argument specifies the minor document version that the caller supports for the XML documents
passed as parameters for this procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error if the version is not valid. On output, this parameter indicates the highest minor document
version that is supported for the highest supported major version. To determine the highest supported
document version, specify NULL for this input parameter and all other required parameters.
Supported versions: 0
If you specify the application handle of the application where the stored procedure is running, the
procedure returns a warning (SQL20458).
xml_filter
An input argument of type BLOB(4K) that specifies a valid XPath query string. Use a filter when you
want to retrieve a single value from an XML output document. For more information, see the topic that
describes XPath filtering.
When the procedure operates in complete mode, this parameter returns an XML document that you
can modify and pass back to the procedure as the xml_input parameter. This approach provides a
programmatic way to create valid XML input documents. For more information, see the topic about
complete mode.
xml_message
An output parameter of type BLOB(64K) that returns a complete XML output document of type Data
Server Message in UTF-8 that provides detailed information about a SQL warning condition. This
document is returned when a call to the procedure results in a SQL warning, and the warning message
indicates that additional information is returned in the XML message output document. If the warning
message does not indicate that additional information is returned, then this parameter is set to NULL.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Example 1: Return the highest supported version of the procedure.
Return Status = 0
Return Status = 0
If the CANCEL_WORK procedure is able to cancel the activity, the XML output document contains the
following content:
Return Status = 0
If the CANCEL_WORK procedure is able to cancel the application, the XML output document contains the
following content:
Example 3: Specify a filter to return the value of a successful cancel work message.
Return Status = 0
Syntax
Procedure parameters
major_version
An input and output argument of type INTEGER that indicates the major document version. On input,
this argument indicates the major document version that the caller supports for the XML documents
passed as parameters in the procedure (see the parameter descriptions for xml_input, xml_output,
Authorization
• Read access to the database.
• Read and write access to the explain tables of the currently connected schema or the SYSTOOLS
schema.
• If materialized query tables (MQTs) are used, you must have CREATE TABLE authorization, and read
and write access to the MQTs
• EXECUTE privilege on the DESIGN_ADVISOR function.
Table 53. Information returned by the DESIGN_ADVISOR - retrieve design advisor recommendations
table function
Column name Data type Description
SCHEMA VARCHAR(128) Schema name of the object or the proposed object
to which this recommendation applies.
NAME VARCHAR(128) Name of the object or the proposed object to which
this recommendation applies.
EXISTS CHAR(1) Indicates that the object exists.
RECOMMENDATION VARCHAR(8) Indicates the recommendation type. Valid values
are:
• M for MQT
• P for database partitioning
• C for MDC
• I for index
• D if the object is not used by the given workload
and can be considered for deletion.
The result can be any combination of these values.
For example "MC" indicates that the table is
recommended as an MQT and an MDC table.
BENEFIT DOUBLE Estimated benefit, in timerons, of the proposed
object or modification to the proposed object of the
query. For base tables or MQTs that have MDC or
partitioning recommendations, this value is NULL.
OVERHEAD DOUBLE Estimated cost, in timerons, to maintain either the
proposed object or the modification to the
proposed object. Indexes are ranked with the
formula BENEFIT - OVERHEAD. MQTs are ranked
with BENEFIT - (0.5 * OVERHEAD). For base
tables or MQTs that have MDC or partitioning
recommendations, this value is NULL.
STATEMENT_NO INTEGER Statement number referred to by this
recommendation. Reflects the statement number
in the ADVISE_WORKLOAD table. When a
recommendation applies to multiple statements,
only one row is returned for each statement.
DISKUSE DOUBLE Estimated size, in MB, of either the recommended
object or the result of modifications to the current
object on disk.
Note: Special characters like "&", "<", ">", "'" (single quotation mark), and """ (double quotation mark)
can be specified by their corresponding HTML entities of "&", "<", ">", "'", and
"quot;".
XML_OUTPUT description
The XML_OUTPUT document is always returned in a UTF-8 code page. Code page conversion is done
for database identifiers, objects, and other possible non-UTF-8 characters. Special characters (see
XML_INPUT options for a list) are translated as well.
Examples
Example 1: An example of an XML_INPUT:
Example 4: A full initialization and procedure call, with the resulting XML outputs.
Initializing the workload:
3 record(s) selected.
Syntax
GET_CONFIG ( major_version , minor_version , requested_locale ,
Procedure parameters
major_version
An input and output argument of type INTEGER that indicates the major document version. On input,
this argument indicates the major document version that the caller supports for the XML documents
passed as parameters in the procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error (+20458) if the version is not valid. On output, this parameter specifies the highest major
document version that is supported by the procedure. To determine the highest supported document
version, specify NULL for this input parameter and all other required parameters.
Supported versions: 1 and 2
minor_version
An input and output argument of type INTEGER that indicates the minor document version. On input,
this argument specifies the minor document version that the caller supports for the XML documents
passed as parameters for this procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error if the version is not valid. On output, this parameter indicates the highest minor document
version that is supported for the highest supported major version. To determine the highest supported
document version, specify NULL for this input parameter and all other required parameters.
Supported versions: 0
requested_locale
An input argument of type VARCHAR(33) that specifies a locale. If the specified language is supported
on the server, translated content is returned in the xml_output and xml_message parameters.
Otherwise, content is returned in the default language. Only the language and possibly the territory
information is used from the locale. The locale is not used to format numbers or influence the
document encoding. For example, key names and values are not translated. The only translated
portion of the XML output and XML message documents are the text for hint, display name, and
display unit of each entry. The caller should always compare the requested language to the language
that is used in the XML output document (see the document locale entry in the XML output
document).
Currently, the only supported value for requested_locale is en_US.
xml_input
Currently, this procedure accepts no input. You must specify NULL for this parameter, or an error
(+20458) is raised to indicate that the input is not valid.
xml_filter
An input argument of type BLOB(4K) that specifies a valid XPath query string. Use a filter when you
want to retrieve a single value from an XML output document. For more information, see the topic that
describes XPath filtering.
When the procedure operates in complete mode, this parameter returns an XML document that you
can modify and pass back to the procedure as the xml_input parameter. This approach provides a
programmatic way to create valid XML input documents. For more information, see the topic about
complete mode.
xml_message
An output parameter of type BLOB(64K) that returns a complete XML output document of type Data
Server Message in UTF-8 that provides detailed information about a SQL warning condition. This
document is returned when a call to the procedure results in a SQL warning, and the warning message
indicates that additional information is returned in the XML message output document. If the warning
message does not indicate that additional information is returned, then this parameter is set to NULL.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Example 1: Return the latest version of the procedure.
Return Status = 0
Example 2: Return database and database manager configuration parameters, grouped into categories.
Return Status = 0
<plist version="1.0">
<dict>
<key>Document Type Name</key><string>Data Server Configuration Output</string>
<key>Document Type Major Version</key><integer>2</integer>
<key>Document Type Minor Version</key><integer>0</integer>
<key>Data Server Product Name</key><string>QDB2/AIX64</string>
<key>Data Server Product Version</key><string>9.7.0.0</string>
<key>Data Server Major Version</key><integer>9</integer>
<key>Data Server Minor Version</key><integer>7</integer>
<key>Data Server Platform</key><string>AIX 64BIT</string>
<key>Document Locale</key><string>en_US</string>
<key>Database Manager Configuration Parameter Settings</key>
<dict>
<key>Display Name</key>
<string>Database Manager Configuration Parameter Settings</string>
<key>Application</key>
<dict>
<key>Display Name</key><string>Application</string>
<key>agentpri</key>
<dict>
<key>Display Name</key><string>agentpri</string>
<key>Parameter Value</key>
<dict>
<key>Display Name</key><string>Parameter Value</string>
<key>Value</key><string>-1</string>
<key>Updatable</key><string>No</string>
<key>Hint</key><string></string>
</dict>
<key>Value Flags</key>
<dict>
<key>Display Name</key><string>Value Flags</string>
<key>Value</key><string>NONE</string>
<key>Updatable</key><string>No</string>
<key>Hint</key><string></string>
</dict>
<key>Deferred Value</key>
<dict>
<key>Display Name</key><string>Deferred Value</string>
<key>Value</key><string>-1</string>
<key>Updatable</key><string>Yes</string>
<key>Hint</key><string></string>
</dict>
Return Status = 0
The XML output document contains content that is similar to example 2, but does not group the
configuration parameters into categories.
Example 4: Call the procedure from a function.
Syntax
GET_MESSAGE ( major_version , minor_version , requested_locale ,
Procedure parameters
major_version
An input and output argument of type INTEGER that indicates the major document version. On input,
this argument indicates the major document version that the caller supports for the XML documents
passed as parameters in the procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error (+20458) if the version is not valid. On output, this parameter specifies the highest major
document version that is supported by the procedure. To determine the highest supported document
version, specify NULL for this input parameter and all other required parameters.
If the XML document in the xml_input parameter specifies a Document Type Major Version key, the
value for that key must be equal to the value provided in the major_version parameter, or an error
(+20458) is raised.
Supported versions: 1 and 2
minor_version
An input and output argument of type INTEGER that indicates the minor document version. On input,
this argument specifies the minor document version that the caller supports for the XML documents
passed as parameters for this procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error if the version is not valid. On output, this parameter indicates the highest minor document
version that is supported for the highest supported major version. To determine the highest supported
document version, specify NULL for this input parameter and all other required parameters.
If the XML document in the xml_input parameter specifies a Document Type Minor Version key, the
value for that key must be equal to the value provided in the minor_version parameter, or an error
(+20458) is raised.
Supported versions: 0
requested_locale
An input argument of type VARCHAR(33) that specifies a locale. If the specified language is supported
on the server, translated content is returned in the xml_output and xml_message parameters.
Otherwise, content is returned in the default language. Only the language and possibly the territory
information is used from the locale. The locale is not used to format numbers or influence the
document encoding. For example, key names and values are not translated. The only translated
portion of the XML output and XML message documents are the text for hint, display name, and
display unit of each entry. The caller should always compare the requested language to the language
that is used in the XML output document (see the document locale entry in the XML output
document).
Currently, the only supported value for requested_locale is en_US.
xml_input
An input argument of type BLOB(32MB) that specifies an XML input document (encoded in UTF-8)
that contains input values for the procedure.
For this procedure, the XML input document contains an SQLCODE and uses the following format:
xml_filter
An input argument of type BLOB(4K) that specifies a valid XPath query string. Use a filter when you
want to retrieve a single value from an XML output document. For more information, see the topic that
describes XPath filtering.
The following example selects the value for the SQLSTATE from the XML output document: /plist/
dict/key[.="SQLSTATE"]/following-sibling::dict[1]/key[.="Value"]/following-
sibling::string[1]. If the key is not followed by the specified sibling, an error is returned.
xml_output
An output parameter of type BLOB(32MB) that returns a complete XML output document in UTF-8. If
a filter is specified, this parameter returns a string value. If the stored procedure is unable to return a
complete output document (for example, if a processing error occurs that results in an SQL warning or
error), this parameter is set to NULL.
The XML output is determined by the values that you specify for major_version and minor_version:
When the procedure operates in complete mode, this parameter returns an XML document that you
can modify and pass back to the procedure as the xml_input parameter. This approach provides a
programmatic way to create valid XML input documents. For more information, see the topic about
complete mode.
xml_message
An output parameter of type BLOB(64K) that returns a complete XML output document of type Data
Server Message in UTF-8 that provides detailed information about a SQL warning condition. This
document is returned when a call to the procedure results in a SQL warning, and the warning message
indicates that additional information is returned in the XML message output document. If the warning
message does not indicate that additional information is returned, then this parameter is set to NULL.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Example
Example 1: Return the highest supported version of the procedure.
Return Status = 0
Example 2: Run a script called getmsglong.sql to return the short text message and long text message
for SQL1034.
getmsglong.sql:
Return Status = 0
<plist version="1.0">
<dict>
<key>Document Type Name</key>
<string>Data Server Message Output</string>
<key>Document Type Major Version</key>
<integer>2</integer>
Example 3: Run a script called getmsgshort.sql to return only the short text message for SQL1034.
getmsgshort.sql:
Return Status = 0
<plist version="1.0">
<dict><key>Document Type Name</key><string>Data Server Message Output</string>
<key>Document Type Major Version</key><integer>1</integer>
<key>Document Type Minor Version</key><integer>0</integer>
<key>Data Server Product Name</key><string>QDB2/AIX64</string>
<key>Data Server Product Version</key><string>9.7.0.0</string>
<key>Data Server Major Version</key><integer>9</integer>
<key>Data Server Minor Version</key><integer>7</integer>
<key>Data Server Platform</key><string>AIX 64BIT</string>
<key>Document Locale</key><string>en_US</string>
<key>Short Message Text</key>
<dict>
<key>Display Name</key><string>Short Message Text</string>
<key>Value</key>
<string>
SQL1034C The database is damaged. All applications processing the database
have been stopped.
</string>
<key>Hint</key><string></string>
</dict>
<key>SQLSTATE</key>
<dict>
<key>Display Name</key><string>SQLSTATE</string>
<key>Value</key><string> 58031</string>
<key>Hint</key><string></string>
</dict>
</dict>
</plist>
Return Status = 0
58031
Syntax
GET_SYSTEM_INFO ( major_version , minor_version , requested_locale
Procedure parameters
major_version
An input and output argument of type INTEGER that indicates the major document version. On input,
this argument indicates the major document version that the caller supports for the XML documents
passed as parameters in the procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error (+20458) if the version is not valid. On output, this parameter specifies the highest major
document version that is supported by the procedure. To determine the highest supported document
version, specify NULL for this input parameter and all other required parameters.
If the XML document in the xml_input parameter specifies a Document Type Major Version key, the
value for that key must be equal to the value provided in the major_version parameter, or an error
(+20458) is raised.
Supported versions: 1
minor_version
An input and output argument of type INTEGER that indicates the minor document version. On input,
this argument specifies the minor document version that the caller supports for the XML documents
passed as parameters for this procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error if the version is not valid. On output, this parameter indicates the highest minor document
version that is supported for the highest supported major version. To determine the highest supported
document version, specify NULL for this input parameter and all other required parameters.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Return Status = 0
Return Status = 0
The XML output document contains something similar to the following content:
<plist version="1.0">
<dict><key>Document Type Name</key><string>Data Server System Output</string>
<key>Document Type Major Version</key><integer>1</integer>
<key>Document Type Minor Version</key><integer>0</integer>
<key>Data Server Product Name</key><string>QDB2/AIX64</string>
<key>Data Server Product Version</key><string>9.7.0.0</string>
<key>Data Server Major Version</key><integer>9</integer>
<key>Data Server Minor Version</key><integer>7</integer>
<key>Data Server Platform</key><string>AIX 64BIT</string>
<key>Document Locale</key><string>en_US</string>
<key>Instance Information</key>
<dict>
<key>Display Name</key><string>Instance Information</string>
<key>Instance Name</key>
<dict>
<key>Display Name</key><string>Instance Name</string>
<key>Value</key><string>myinstance</string>
<key>Hint</key><string></string>
</dict>
<key>Partitionable State</key>
<dict>
<key>Display Name</key><string>Partitionable State</string>
<key>Value</key><integer>0</integer>
<key>Hint</key><string></string>
</dict>
<key>Number of Database Partitions</key>
<dict>
<key>Display Name</key><string>Number of Database Partitions</string>
<key>Workload Information</key>
<dict>
<key>Display Name</key><string>Workload Information</string>
<key>1</key>
<dict>
<key>Display Name</key><string>1</string>
<key>Workload Name</key>
<dict>
<key>Display Name</key><string>Workload Name</string>
<key>Value</key><string>SYSDEFAULTUSERWORKLOAD</string>
<key>Hint</key><string></string>
</dict>
<key>Evaluation Order</key>
<dict>
<key>Display Name</key><string>Evaluation Order</string>
<key>Value</key><integer>1</integer>
<key>Hint</key><string></string>
</dict>
<key>Creation Time</key>
<dict>
<key>Display Name</key><string>Creation Time</string>
<key>Value</key><string>2008-04-21-15.14.32.955296</string>
<key>Hint</key><string></string>
Return Status = 0
The XML output document will contain the same content that is shown for Example 2.
Example 4: Call the procedure from a function.
Syntax
SET_CONFIG ( major_version , minor_version , requested_locale ,
Procedure parameters
major_version
An input and output argument of type INTEGER that indicates the major document version. On input,
this argument indicates the major document version that the caller supports for the XML documents
passed as parameters in the procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error (+20458) if the version is not valid. On output, this parameter specifies the highest major
document version that is supported by the procedure. To determine the highest supported document
version, specify NULL for this input parameter and all other required parameters.
If the XML document in the xml_input parameter specifies a Document Type Major Version key, the
value for that key must be equal to the value provided in the major_version parameter, or an error
(+20458) is raised.
Supported versions: 1
minor_version
An input and output argument of type INTEGER that indicates the minor document version. On input,
this argument specifies the minor document version that the caller supports for the XML documents
passed as parameters for this procedure (see the parameter descriptions for xml_input, xml_output,
and xml_message). The procedure processes all XML documents in the specified version, or returns
an error if the version is not valid. On output, this parameter indicates the highest minor document
version that is supported for the highest supported major version. To determine the highest supported
document version, specify NULL for this input parameter and all other required parameters.
If the XML document in the xml_input parameter specifies a Document Type Minor Version key, the
value for that key must be equal to the value provided in the minor_version parameter, or an error
(+20458) is raised.
Supported versions: 0
requested_locale
An input argument of type VARCHAR(33) that specifies a locale. If the specified language is supported
on the server, translated content is returned in the xml_output and xml_message parameters.
Otherwise, content is returned in the default language. Only the language and possibly the territory
information is used from the locale. The locale is not used to format numbers or influence the
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Example 1: Return the latest version of the procedure.
Return Status = 0
Example 2: Run a script called setconfig.sql that updates a few database and database manager
configuration parameters.
setconfig.sql:
call sysproc.set_config(1,0,'en_US',blob('
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>Document Type Name</key><string>Data Server Set Configuration Input</string>
<key>Document Type Major Version</key><integer>1</integer>
<key>Document Type Minor Version</key><integer>0</integer>
<key>Document Locale</key><string>en_US</string>
<key>Database Manager Configuration Parameter Settings</key>
<dict>
<key>diaglevel</key><dict><key>Parameter Value</key>
<dict>
<key>Value</key><string>4</string>
</dict>
</dict>
<key>fcm_num_buffers</key>
<dict>
<key>Parameter Value</key>
<dict>
<key>Value</key><string>4096</string>
</dict>
<key>Value Flags</key>
<dict>
<key>Value</key><string>MANUAL</string>
</dict>
</dict>
<key>instance_memory</key>
<dict>
<key>Deferred Value</key>
<dict>
<key>Value</key><string>7424</string>
</dict>
<key>Deferred Value Flags</key>
<dict>
<key>Value</key><string>AUTOMATIC</string>
</dict>
</dict>
</dict>
<key>Database Partition</key>
<dict>
<key>All</key>
<dict>
<key>Database Configuration Parameter Settings</key>
<dict>
<key>avg_appls</key>
<dict>
<key>Parameter Value</key>
<dict>
<key>Value></key><string>2</string>
</dict>
<key>Value Flags</key>
<dict>
<key>Value</key><string>AUTOMATIC</string>
</dict>
</dict>
<key>database_memory</key>
Return Status = 0
The output XML document contains something similar to the following content:
Return Status = 0
4096
Authorization
The following authorization is required:
• EXECUTE privilege on the routine. EXECUTE privilege on this routine can be granted only by the security
administrator (SECADM)
Syntax
ADMIN_REFRESH_CONFIG ( )
type
Procedure Parameters
type
Usage Notes
Calling ADMIN_REFRESH_CONFIG will refresh the token configuration of the instance. On DPF or Db2
pureScale instances, the configuration of the local instance will be refreshed first. If the refresh of the
local instance is successful, an RPC will be sent to other nodes and they will process the configuration
update.
Example
Return Status = 0
DBCFG administrative view and DB_GET_CFG table function - Retrieve database configuration
parameter information
The DBCFG administrative view and the DB_GET_CFG table function retrieve database configuration
parameter information for the currently connected database for all active database members.
To ensure that information is retrieved from all database members in the instance, run the ACTIVATE
DATABASE command before using the administrative view or table function. Depending on whether you
are using the administrative view or the table function, refer to one of the following sections:
• “DBCFG administrative view” on page 310
• “DB_GET_CFG table function” on page 311
Authorization
One of the following authorizations is required:
• SELECT privilege on the DBCFG administrative view
• CONTROL privilege on the DBCFG administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve the automatic maintenance settings in the database configuration that are stored in
memory for all active database members.
SELECT DBPARTITIONNUM, NAME, VALUE FROM SYSIBMADM.DBCFG WHERE NAME LIKE 'auto_%'
6 record(s) selected.
Example 2: Retrieve all the database configuration parameters values stored on disk for all active
database members.
Syntax
DB_GET_CFG ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the DB_GET_CFG table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
30 record(s) selected.
Information returned
Table 56. Information returned by the DBCFG administrative view and the DB_GET_CFG table function
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:
• NONE - no additional
information
• AUTOMATIC - the configuration
parameter has been set to
automatic
• COMPUTED - the configuration
parameter has been set to a
computed value
DBMCFG administrative view and DBM_GET_CFG table function - Retrieve database manager
configuration parameter information
The DBMCFG administrative view and the DBM_GET_CFG table function returns database manager
configuration parameter information including the values in memory and the values stored on disk.
Depending on whether you are using the administrative view or the table function, refer to one of the
following sections:
• “DBMCFG administrative view” on page 313
• “DBM_GET_CFG table function” on page 316
Authorization
One of the following authorizations is required:
Examples
Example 1: Retrieve values for all the database manager configuration parameters stored on disk:
NAME DEFERRED_VALUE
-------------------------------- -------------------...----
agent_stack_sz 0
agentpri -1
alt_diagpath
alt_diagpath_resolved
alternate_auth_enc AES_ONLY
aslheapsz 15
audit_buf_sz 0
authentication SERVER
catalog_noauth YES
cf_diaglevel 2
cf_diagpath /home/hotellnx93/db2docs2/sqllib/db2dump/
cf_diagpath_resolved /home/hotellnx93/db2docs2/sqllib/db2dump/
cf_mem_sz 131072
cf_num_conns 16
cf_num_workers 1
clnt_krb_plugin
...
comm_bandwidth 0.000000e+00
comm_exit_list
conn_elapse 0
cpuspeed 4.000000e-05
cur_eff_arch_lvl V:10 R:5 M:0 F:1 I:0 SB:0
cur_eff_code_lvl V:10 R:5 M:0 F:1 I:0 SB:0
dft_account_str
dft_mon_bufpool OFF
...
dft_mon_timestamp ON
dft_mon_uow OFF
...
jdk_path /home/hotellnx93/db2docs2/sqllib/java/jdk64
...
ssl_svcename 22711
ssl_svr_keydb /GSKit/Keystore/key.kdb
ssl_svr_label
ssl_svr_stash /GSKit/Keystore/key.sth
Syntax
DBM_GET_CFG ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the DBM_GET_CFG table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Retrieve the workload manager settings from the database manager configuration:
NAME VALUE
-------------------------------- --------------------
wlm_disp_concur 128
wlm_disp_cpu_shares NO
wlm_disp_min_util 5
wlm_dispatcher YES
4 record(s) selected.
Information returned
Table 57. Information returned by the DBMCFG administrative view and DBM_GET_CFG table function
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:
• NONE - no additional
information
• AUTOMATIC - the configuration
parameter has been set to
automatic
Syntax
DB_MEMBERS ( )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Retrieve instance information:
5 record(s) selected.
Authorization
One of the following authorizations is required:
• SELECT privilege on the DB2_CLUSTER_HOST_STATE administrative view
• CONTROL privilege on the DB2_CLUSTER_HOST_STATE administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
6 record(s) selected.
Syntax
DB2_GET_CLUSTER_HOST_STATE ( hostname )
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the DB2_GET_CLUSTER_HOST_STATE table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
.
Example
The following example uses the DB2_GET_CLUSTER_HOST_STATE table function to retrieve information
about the host named so3 in a Db2 pureScale instance with four members and two CFs.
1 record(s) selected.
Information returned
Authorization
The following authorizations is required:
• SELECT privilege on the DB2_INSTANCE_ALERTS administrative view
Example
The following example demonstrates the kind of information you can retrieve using the
DB2_INSTANCE_ALERTS administrative view.
The following is an example of output for this query. The columns have been placed on separate rows for
readability.
MESSAGE
-------------------------------------------------------------------------------
Restart light failed for member 0 on host(s) hostC. Check the db2diag.log for
messages concerning a restart light or database crash recovery failure on these
hosts for member 0. See the IBM Knowledge Center for more details.
ACTION
-------------------------------------------------------------------------------
This alert must be cleared manually with the command:
db2cluster -clear -alert -member 0
IMPACT
-------------------------------------------------------------------------------
Restart light will not succeed for member 0 on the hosts listed until this
alert has been cleared.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the administrative view
Examples
The following example uses the DB2_MEMBER administrative view to display the status of all members in
the database instance. This is appropriate for the following kinds of instance:
• A Db2 pureScale instance
• A partitioned or non-partitioned database instance using the High Availability Disaster Recovery (HADR)
feature.
Execute the following query to display the status of all members in the database instance:
3 record(s) selected.
The following example uses the DB2_CF administrative view to display the status of all CFs in the
database instance. This is appropriate for a Db2 pureScale instance, only.
Execute the following query to display the status of all cluster caching facilities in the database instance:
2 record(s) selected.
Syntax
DB2_GET_INSTANCE_INFO ( id , home_host ,
Authorization
EXECUTE privilege on the DB2_GET_INSTANCE_INFO table function.
Examples
The following example uses the DB2_GET_INSTANCE_INFO table function to retrieve information from a
Db2 pureScale instance with four members and two cluster caching facilities. In this example, member
number 2 is being restarted on the host called so1:
6 record(s) selected.
Information returned
Note:
1. CATCHUP includes a percentage value as part of the returned state. This percentage value represents
the amount to which the secondary cluster caching facility has caught up to the current state of the
primary caching facility.
Authorization
One of the following authorizations is required:
• SELECT privilege on the view
Examples
The following example demonstrates the information you can obtain using the ENV_CF_SYS_RESOURCES
administrative view.
Information returned
Table 65. Possible values for the NAME and DATATYPE columns
Information type Name Data Types Description
Operating system HOST_NAME VARCHAR(256) Name of the host the
cluster caching facility is
running on.
Physical memory MEMORY_TOTAL BIGINT Total size of physical
memory.
MEMORY_FREE BIGINT Amount of free physical
memory.
MEMORY_SWAP_TOTAL BIGINT Total amount of swap
space.
MEMORY_SWAP_FREE BIGINT Amount of free swap
space.
Virtual memory VIRTUAL_MEM_TOTAL BIGINT Total amount of virtual
memory on the system.
VIRTUAL_MEM_RESERVED BIGINT Amount of reserved
virtual memory.
Authorization
One of the following authorizations is required:
• SELECT privilege on the ENV_FEATURE_INFO administrative view
• CONTROL privilege on the ENV_FEATURE_INFO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Request the installed product offerings license information.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
• DBADM authority
Syntax
ENV_GET_DB2_EDU_SYSTEM_RESOURCES ( member )
Information returned
Examples
1. List the EDU_NAME and DB2_PROCESS_ID on all members.
EDU_NAME DB2_PROCESS_ID
----------------------------------- --------------------
db2agntdp (TEST) 4615
db2agntdp (TEST) 4615
db2agent (TEST) 4615
db2evmli (DB2DETAILDEADLOCK) 4615
db2pcsd (TEST) 4615
db2fw3 (TEST) 4615
db2fw2 (TEST) 4615
33 record(s) selected.
33 record(s) selected.
Syntax
ENV_GET_DB2_SYSTEM_RESOURCES ( member )
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
4 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
The schema is SYSPROC.
Example
TOTAL_BYTES_SENT
----------------
528451011980
272061746005
0
Information returned
ENV_GET_REG_VARIABLES table function - Retrieve database registry settings that are in use
The ENV_GET_REG_VARIABLES table function returns the database registry settings from one or all
database members.
Note: The ENV_GET_REG_VARIABLES table function replaces the deprecated REG_VARIABLES
administrative view. The ENV_GET_REG_VARIABLESfunction is different in that it allows for a single
parameter value to denote a specific member to query, and returns an addition result for the registry
setting currently stored on disk.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the ENV_GET_REG_VARIABLES table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, one of the following privileges or authorities is also required:
• EXECUTE privilege on the ENV_GET_REG_VARIABLES table function
Syntax
ENV_GET_REG_VARIABLES ( member , showall )
Information returned
Table 70. Information returned by the ENV_GET_REG_VARIABLES table function
Column name Data type Description
MEMBER SMALLINT member - Database member monitor
element
REG_VAR_NAME VARCHAR(256) Name of the database registry
variable.
REG_VAR_VALUE VARCHAR(2048) Current setting of the database
registry variable in memory.
REG_VAR_ON_ VARCHAR(2048) Current setting of the database
DISK_VALUE registry variable on disk.
IS_AGGREGATE SMALLINT Indicates whether or not the
database 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.
AGGREGATE_NAME VARCHAR(256) Name of the aggregate if the
database registry variable is
currently obtaining its value from a
configured aggregate. If the registry
variable is not being set through an
aggregate, or is set through an
aggregate but has been overridden,
the value of AGGREGATE_NAME is
NULL.
LEVEL CHAR(1) Indicates the level at which the
database registry variable acquires
its value. The possible return values
and the corresponding levels that
they represent are:
• I = instance
• G = global
• N = database partition
• E = environment
Examples
• Show all database registry settings (including registry variables that are not set) for all database
members:
• In this example, the registry variable DB2DBDFT, which specifies the database alias name to use for
implicit connections, is set to CORP_1. This is done before the database instance starts:
db2set db2dbdft=CORP_1
db2start
Then you can issue a query to show that registry variable setting:
VALUE ON_DISK_VALUE
-------------------- --------------------
CORP_1 CORP_1
1 record(s) selected.
To demonstrate the difference between in memory and on disk values for the registry settings, the
DB2DBDFT registry variable is then altered:
db2set db2dbdft=DEPT_MAJOR
Running the same query as the previous one, shows that this new value is immediately picked up by the
ENV_GET_REG_VARIABLES function:
VALUE ON_DISK_VALUE
-------------------- --------------------
CORP_1 DEPT_MAJOR
1 record(s) selected.
However, note that the in memory value will not change to the new value until the database instance is
restarted.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
ENV_GET_INSTANCE_CODE_LEVELS ( )
Information returned
Example
Simulation of an online rolling update from Version 10.5 Fix Pack 1 to Fix Pack 2 for an instance named
"INST1". It is assumed that Fix Pack 2 introduced a new architecture level but the section level remained
unchanged since Version 10.5.
...CODE_LEVEL LAST_UPDATED
...----------------------------- --------------------------
...V:10 R:5 M:0 F:1 I:0 SB:0 2012-10-06-19.12.00.000000
...V:10 R:5 M:0 F:1 I:0 SB:0 2012-10-06-19.12.00.000000
...V:10 R:5 M:0 F:1 I:0 SB:0 2012-10-06-19.12.00.000000
...V:10 R:5 M:0 F:1 I:0 SB:0 2012-10-06-19.12.00.000000
...V:10 R:5 M:0 F:1 I:0 SB:0 2012-10-06-19.12.00.000000
...V:10 R:5 M:0 F:1 I:0 SB:0 2012-10-06-19.12.00.000000
6 record(s) selected.
2. The user updates two cluster caching facilities (CFs) using the following command on both CFs:
Query output:
6 record(s) selected.
3. The three members are subsequently moved to Fix Pack 2 using the same installFixPack
command:
Query output:
6 record(s) selected.
4. The cluster is then committed at the new level of code, using the following command:
./installFixPack -commit_new_level
Query output:
6 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Note:
1
These metrics have been aggregated across all logical processors on the system.
On the AIX operating system, the metrics are for the Workload partition (WPAR) and Logical partition
(LPAR) on which the database server is running.
Usage notes
• In a virtualized environment (such as VMWare ESX) the database system might be unable to determine
the CPU topology such as CPU_HMT_DEGREE or CPU_CORES_PER_SOCKET. This occurs because of
limited information that the hypervisor makes available to the virtualized operating system. In such
cases, CPU_CORES_PER_SOCKET and CPU_HMT_DEGREE will have a value of 1.
• To return accurate results, the ENV_GET_SYSTEM_RESOURCES table function takes more than 1
second on AIX, HP, and Windows operating systems.
Examples
Example 1: Obtain operating system information for every member in a three-member Db2 pureScale
setup:
3 record(s) selected.
Example 2: Obtain memory information for the system hosting this database on a Db2 Enterprise Server
Edition system:
Sample output is as follows. Because of space constraints, the output is continued on a second line.
1 record(s) selected
Example 3: Find the load times for all the systems hosting the database, in a four member partitioned
database environment.
4 record(s) selected.
Example 4:
4 record(s) selected.
Example
Request information about the current instance.
1 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the ENV_PROD_INFO administrative view
• CONTROL privilege on the ENV_PROD_INFO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Request the installed database product information.
INSTALLED_PROD VARCHAR(26) Identifiers for database products that are installed on the
system.
INSTALLED_PROD_FULLNAME VARCHAR(100) Full name of installed database products. Column values will be
displayed in English in uppercase. Words are separated with an
underscore character.
LICENSE_TYPE VARCHAR(50) Name of the type of license that is installed for the product. The
possible return values are:
• 12_MONTHS_LICENSE_AND_SUBSCRIPTION
• AUTHORIZED_USER
• AUTHORIZED_USER_SINGLE_INSTALL_OPTION
• CLIENT_DEVICE
• CPU
• CPU_OPTION
• HOST_SERVER_AND_MSU
• LICENSE_NOT_REGISTERED
• MANAGED_PROCESSOR
• N/A
• RESTRICTED
• TRIAL
• UNWARRANTED
• USER
Authorization
One of the following authorizations is required:
• SELECT privilege on the ENV_SYS_INFO administrative view
• CONTROL privilege on the ENV_SYS_INFO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Request information about the system.
1 record(s) selected.
Information returned
Explain routines
This grouping of routines and views can be used to retrieve information about the access plan that the
optimizer chooses for an SQL statement or XQuery statement.
EXPLAIN_GET_MSGS
The EXPLAIN_GET_MSGS table function queries the EXPLAIN_DIAGNOSTIC and
EXPLAIN_DIAGNOSTIC_DATA Explain tables, and returns formatted messages.
Syntax
EXPLAIN_GET_MSGS ( explain-requester , explain-time , source-name
sectno , locale )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• EXPLAIN authority
Information returned
Examples
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
MSG
------------------------------------------------------------------------
EXP0012W Invalid access request. The index "index1" could not be found.
Line number "554", character number "20".
EXP0012W Invalid access request. The index "index2" could not be found.
Line number "573", character number "20".
EXP0015W Invalid join request. Join refers to tables that are not in
the same FROM clause. Line number "573", character number "20".
EXPLAIN_FORMAT_STATS
This scalar function is used to display formatted statistics information which is parsed and extracted from
explain snapshot captured for a given query.
Syntax
EXPLAIN_FORMAT_STATS ( snapshot )
Function parameters
snapshot
An input argument of type BLOB(10M) that is the explain snapshot captured for a given query. It is
stored as snapshot column of explain table EXPLAIN_STATEMENT
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Information returned
The data type of the result is CLOB(50M).
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
Tablespace Context:
-------------------
Name: USERSPACE1
Overhead: 7.500000
Transfer Rate: 0.060000
Prefetch Size: 32
Extent Size: 32
Type: Database managed
Partition Group Name: NULLP
Buffer Pool Identifier: 0
Column Information:
--------------------
Number: 1
Name: C1
Statistics Available: Yes
Column Statistics:
------------------
Schema name of the column type: SYSIBM
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
Quantile Statistics:
Valcount Distcount Value
---------- ----------- -----------
0 0 1
2 0 1
3 0 2
4 0 4
5 0 4
Column Information:
--------------------
Number: 1
Name: C1
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
Column Information:
--------------------
Number: 2
Name: C2
Statistics Available: Yes
Column Statistics:
------------------
Schema name of the column type: SYSIBM
Name of column type: INTEGER
Authorization
One of the following authorities or privileges is required to execute the routine:
Example
The following example assumes that you are mining the data collected in the activity event monitor over a
period of time and using the following query, you notice a particularly expensive SQL statement in terms
of CPU cost.
SELECT APPL_ID,
UOW_ID,
ACTIVTY_ID,
USER_CPU_TIME
FROM ACTIVITY_A
ORDER BY USER_CPU_TIME
The following example shows output from this query. The application with an ID of
N2.DB2INST1.0B5A12222841 is using a large amount of CPU time.
2 record(s) selected.
You can use the EXPLAIN_FROM_ACTIVITY procedure to investigate the access plan for this activity, to
determine if the activity could benefit from tuning, for example, by adding an index.
Usage notes
In order to run Explain on the section of the activity, you must specify the COLLECT ACTIVITY DATA WITH
SECTION clause when you enable collection of activity data, so that the section is collected with the
activity information. If there is no section stored with the identified activity entry, SQL20501 is returned.
If section actuals were not collected for an activity, the section explain will succeed, but the Explain
output will not include actuals information. Section actuals are not collected in the following cases:
• The activity specified as input was captured using the WLM_CAPTURE_ACTIVITY_IN_PROGRESS
stored procedure. In this case, the value of the partial_record element in the activity logical group is 1.
• The activity event monitor ACTIVITY table is missing the SECTION_ACTUALS element.
• The section executed is a static section and it has not been rebound since applying Db2 Version 9.7 Fix
Pack 1.
• Section actuals were not enabled for the section that was captured. Section actuals are enabled using
the section_actuals database configuration parameter or for a specific application using the
WLM_SET_CONN_ENV procedure. By default, section actuals are disabled.
Note: To verify that section actuals were collected for an activity, check whether the SECTION_ACTUALS
element in the ACTIVITY table has a length greater than 0.
Note: The section_actuals setting specified by the WLM_SET_CONN_ENV procedure for an application
takes effect immediately. Section actuals will be collected for the next statement issued by the
application.
Note: In a partitioned database environment, section actuals will be collected only on members where
activity data is collected. To collect actuals on all members, ensure the activity is collected using the
COLLECT ACTIVITY DATA ON ALL MEMBERS WITH DETAILS, SECTION clause. If the user wants to enable
collection at all members for a particular application, they can include the <collectactpartition> tag with a
value of "ALL" in the second argument when calling the WLM_SET_CONN_ENV procedure.
Authorization
One of the following authorities or privileges is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• EXPLAIN authority
In addition, the privileges held by the authorization ID of the session, including privileges granted to
groups, must include at least one of the following:
• INSERT privilege on the explain tables in the specified schema
• CONTROL privilege on the explain tables in the specified schema
• DATAACCESS authority
Syntax
EXPLAIN_FROM_CATALOG ( pkgschema , pkgname , pkgversion ,
Procedure parameters
pkgschema
An input argument of type VARCHAR(128) specifying the schema of the package containing the
section to be explained. If pkgschema is null or an empty string, SQL2032N is returned.
Usage notes
If no section can be found corresponding to the input parameters, SQL20501 is returned.
The output parameters explain_requester, explain_time, source_name, source_schema, source_version
comprise the key used to look up the Explain information for the section in the Explain tables. Use these
parameters with any existing Explain tools (for example, db2exfmt) to format the explain information
retrieved from the section.
The procedure does not issue a COMMIT statement after inserting into the Explain tables. It is the
responsibility of the caller of the procedure to issue a COMMIT.
Example
The following example demonstrates how to explain a static statement that was compiled and exists in
the catalogs. First, you can identify the section by selecting from the SYSCAT.STATEMENTS catalog view,
for example:
SELECT pkgschema,
pkgname,
version,
Sectno
FROM SYSCAT.STATEMENTS
WHERE TEXT = 'select count(*) from syscat.tables'
2 record(s) selected.
Then pass the pkgschema, pkgname, version and sectno identification information into the
EXPLAIN_FROM_CATALOG procedure, for example:
Authorization
One of the following authorities or privileges is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• EXPLAIN authority
In addition, the privileges held by the authorization ID of the session, including privileges granted to
groups, must include at least one of the following:
• INSERT privilege on the explain tables in the specified schema
• CONTROL privilege on the explain tables in the specified schema
• DATAACCESS authority
Syntax
EXPLAIN_FROM_DATA ( section
, source_version )
Procedure parameters
section
An input argument of type BLOB(134M) that contains the section to be explained. You can obtain the
section from various sources, including event monitor tables and the catalog tables. SQL20503N is
returned in the following situations:
• The input section is not a valid section
• The input section is from a database with a different operating system
Restrictions
The section that is passed as input to the EXPLAIN_FROM_DATA stored procedure must be obtained
from a database whose architecture is the same as the database used for the EXPLAIN_FROM_DATA
stored procedure call.
Usage notes
The input section can be obtained from a number of different sources:
• Activity event monitor
• Package cache event monitor
• Catalog tables
• Any user table or input source that has made a copy of the section from one of the locations listed
previously.
The output parameters explain_requester, explain_time, source_name, source_schema, source_version
comprise the key used to look up the Explain information for the section in the Explain tables. Use these
parameters with any existing Explain tools (for example, db2exfmt) to format the explain information
retrieved from the section.
The procedure does not issue a COMMIT after inserting into the Explain tables. It is the responsibility of
the caller of the procedure to issue a COMMIT.
BEGIN
DECLARE EXECUTABLE_ID VARCHAR(32) FOR BIT DATA; --
DECLARE SECTION BLOB(134M); --
DECLARE STMT_TEXT CLOB(2M); --
DECLARE EXPLAIN_SCHEMA VARCHAR(128); --
Authorization
One of the following authorities or privileges is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
Syntax
EXPLAIN_FROM_SECTION ( executable_id , section_source_type ,
, source_version )
Procedure parameters
executable_id
An input argument of type VARCHAR(32) FOR BIT DATA that uniquely identifies a section to be
explained. If this argument is null or an empty string, SQL2032 is returned.
section_source_type
An input argument of type CHAR(1) that specifies the source of the section to be explained. Valid
values are:
• M - Section is obtained from the in-memory package cache
• P - Section is obtained from a package cache event monitor. Either regular or unformatted event
tables can be used as the output type for the event monitor.
For static SQL, if the section_source_type is M and the section cannot be located in the package cache,
the catalog tables are searched for the section.
section_source_name
An input argument of VARCHAR(128) that specifies the name of a package cache event monitor if the
section_source_type is P. If the section_source_type is M, the name of a package cache event monitor
can be optionally specified. The event monitor is searched for the section if the section cannot be
found in the package cache (for example, if the section was flushed from the package cache before
the EXPLAIN_FROM_SECTION stored procedure was invoked). If the source input event monitor is
not a package cache event monitor created with the COLLECT DETAILED DATA option, SQL0204N is
returned. If the caller does not have SELECT privilege on the package cache event monitor table,
SQL0551N is returned.
member
An input argument of type INTEGER that specifies the member where the section to be explained
resides in memory if the section_source_type is M. If -1 is specified, the procedure searches for the
section on the current coordinator member and the section compilation member. This argument is
ignored if the section_source_type is anything other than M.
Usage notes
If the section corresponding to the input executable ID cannot be found, SQL20501 is returned. The input
executable_id can be obtained from the following sources
• Activity event monitor
• Package cache event monitor
• MON_GET_ACTIVITY_DETAILS table function
• MON_GET_PKG_CACHE_STMT table function
• WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES table function
• WLM_GET_SERVICE_CLASS_AGENTS table function
• MON_GET_PKG_CACHE_STMT_DETAILS table function
• MON_GET_APPL_LOCKWAIT table function
The output parameters explain_requester, explain_time, source_name, source_schema, source_version
comprise the key used to look up the information for the section in the Explain tables. Use these
parameters with any existing Explain tools (for example, db2exfmt) to format the explain information
retrieved from the section.
The procedure does not issue a COMMIT statement after inserting into the Explain tables. It is the
responsibility of the caller of the procedure to issue a COMMIT.
Example
This example shows how to identify and analyze a particularly expensive statement in the package cache
by looking at the monitoring metrics available per section. First, issue a query similar to the following
SELECT statement to determine the CPU time usage of sections.
SELECT executable_id,
Total_cpu_time,
Varchar(stmt_text, 100) as stmt_text
FROM TABLE(MON_GET_PKG_CACHE_STMT (NULL, NULL,NULL, -1)) AS T
2 record(s) selected.
...STMT_TEXT
...----------------------
...SELECT * FROM SYSCAT.TABLES
...INSERT INTO T1 VALUES(123)
2 record(s) selected.
To examine the access plan for the expensive SELECT statement, pass its executable_id to the
EXPLAIN_FROM_SECTION procedure. Place the output in the Explain tables in the MYSCHEMA schema.
CALL EXPLAIN_FROM_SECTION
( x'01000000000000001200000000000000000000000200200811261904103698',
'M', NULL, 0, 'MYSCHEMA', ?, ?, ?, ?, ? )
Monitor views
Monitor views are an ideal place to start when interested in basic monitoring.
These views provide a condensed representation of monitoring information, displaying the highlights, as
well as providing some of the standard calculations of most interest, such as buffer pool hit ratio.
Views are very similar to table functions; they return data in table format, but unlike table functions, they
do not require any input parameters.
The monitor views return metrics on various database activities, for example:
• MON_BP_UTILIZATION returns key monitoring metrics, including hit ratios and average read and write
times, for all buffer pools and all database partitions in the currently connected database.
• MON_CURRENT_SQL returns metrics for all activities that were submitted on all members of the
database and have not yet been completed, including a point-in-time view of currently executing SQL
statements.
• MON_DB_SUMMARY returns metrics aggregated over all service classes.
• MON_LOCKWAITS returns information about agents working on behalf of applications that are waiting
to obtain locks in the currently connected database.
• MON_SERVICE_SUBCLASS_SUMMARY returns metrics for all service subclasses, showing work
executed per service class.
• MON_CURRENT_UOW returns metrics for all units of work.
• MON_WORKLOAD_SUMMARY returns metrics for all workloads, showing incoming work per workload.
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_BP_UTILIZATION administrative view
• CONTROL privilege on the MON_BP_UTILIZATION administrative view
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_CONNECTION_SUMMARY administrative view
• CONTROL privilege on the MON_CONNECTION_SUMMARY administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_CURRENT_SQL administrative view
• CONTROL privilege on the MON_CURRENT_SQL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_CURRENT_UOW administrative view
• CONTROL privilege on the MON_CURRENT_UOW administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Example
The following example retrieves the application handle, the unit of work ID, the elapsed time, and the
total number of rows read and rows returned, for all units of work that have been executed for more than
10 seconds.
3 record(s) selected.
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_DB_SUMMARY administrative view
• CONTROL privilege on the MON_DB_SUMMARY administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Information returned
MON_LOCKWAITS administrative view - Retrieve metrics for applications that are waiting to obtain
locks
The MON_LOCKWAITS administrative view returns information about agents working on behalf of
applications that are waiting to obtain locks in the currently connected database.
This administrative view is useful for identifying locking problems.
This administrative view replaces the SNAPLOCKWAIT administrative view, which is deprecated.Version
9.7 Fix Pack 1 and might be discontinued in a future release.
The schema is SYSIBMADM.
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_LOCKWAITS administrative view
• CONTROL privilege on the MON_LOCKWAITS administrative view
• DATAACCESS authority
Information returned
Table 82. Information returned by the MON_LOCKWAITS administrative view
Column name Data type Description or Monitor element
LOCK_NAME VARCHAR(32) lock_name - Lock name
You can use the
MON_FORMAT_LOCK_
NAME routine to format
this internal binary
lock name and
obtain more details
regarding the lock,
such as the table and table
space that a table
lock references.
LOCK_OBJECT_TYPE VARCHAR(32) lock_object_type - Lock object type waited on
LOCK_WAIT_ELAPSED_TIME INTEGER The time elapsed since the agent started waiting to
obtain the lock. This value is given in seconds.
TABSCHEMA VARCHAR(128) table_schema - Table schema name
For locks that do not reference a table, NULL is
returned.
HLD_USERID VARCHAR(128) The current authorization ID for the session being used
by the application that is holding this lock.
HLD_CURRENT_ CLOB(2MB) SQL statement text that is currently associated with the
STMT_TEXT application that is holding the lock. Note that this is not
necessarily the statement that is causing the lock.
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_PKG_CACHE_SUMMARY administrative view
• CONTROL privilege on the MON_PKG_CACHE_SUMMARY administrative view
• DATAACCESS authority
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_SERVICE_SUBCLASS_SUMMARY administrative view
• CONTROL privilege on the MON_SERVICE_SUBCLASS_SUMMARY administrative view
• DATAACCESS authority
Information returned
Authorization
This administrative view provides critical information for monitoring performance as well as space
utilization.
This administrative view is a replacement for the TBSP_UTILIZATION administrative view.
The schema is SYSIBMADM.
One of the following authorizations is required:
• SELECT privilege on the MON_TBSP_UTILIZATION administrative view
• CONTROL privilege on the MON_TBSP_UTILIZATION administrative view
• DATAACCESS authority
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_TRANSACTION_LOG_UTILIZATION administrative view
• CONTROL privilege on the MON_TRANSACTION_LOG_UTILIZATION administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Usage notes
For databases that are configured for infinite logging, the values for LOG_UTILIZATION_PERCENT and
TOTAL_LOG_AVAILABLE_KB are NULL.
Authorization
One of the following authorizations is required:
• SELECT privilege on the MON_WORKLOAD_SUMMARY administrative view
• CONTROL privilege on the MON_WORKLOAD_SUMMARY administrative view
• DATAACCESS authority
Information returned
Syntax
EVMON_FORMAT_UE_TO_TABLES ( evmon_type , xsrschema ,
Procedure parameters
evmon_type
An input parameter of type VARCHAR(128) that represents the type of data stored in the unformatted
event table. The possible values are as follows:
LOCKING
Data stored in the unformatted event table is from a locking event monitor.
PKGCACHE
Data stored in the unformatted event table is from a PACKAGE CACHE event monitor.
UOW
Data stored in the unformatted event table is from a UOW event monitor.
xsrschema
An input parameter of type VARCHAR (128) that specifies the first-part of the name of the XSR object
that describes how data from the UE file corresponds to columns in tables. The second-part of the
XSR object name is derived from the xsrobjectname parameter. The complete XSR object name is
defined as xsrschema.xsrobjectname. If this value is NULL, then the authorization ID of the current
session user is used.
xsrobjectname
An input parameter of type VARCHAR (128) that specifies the second-part of the name of the XSR
object that describes how data from the UE file corresponds to columns in tables. The first-part of the
Authorization
EXECUTE privilege on the EVMON_FORMAT_UE_TO_TABLES stored procedure.
SELECT privilege on the unformatted event table, if you did not create it.
CREATE privilege to create the relational tables in the specified SQL schema.
INSERT privilege to insert into the relational tables, if you did not create them.
All privileges required by the XDB_DECOMP_XMP_FROM_QUERY procedure.
Usage notes
Maximum XML document size of 100 MB
EVMON_FORMAT_UE_TO_XML has a maximum XML document size of 100 MB.
Since EVMON_FORMAT_UE_TO_TABLES uses EVMON_FORMAT_UE_TO_XML, this same 100 MB
restriction applies to EVMON_FORMAT_UE_TO_TABLES.
Relationship of records in a UE table to the output of the EVMON_FORMAT_UE_TO_TABLES table
function
There is not a one-to-one mapping between the records written to the UE table and the output of the
EVMON_FORMAT_UE_TO_TABLES procedure. Some events generate multiple records in the UE table;
some result in just one record being added. When writing data to relational tables, the
EVMON_FORMAT_UE_TO_TABLES procedure might, in some cases combine information in multiple
UE table records into a single relational table, or it may produce more than one row in different output
tables.
Table creation
In order for decomposition to occur, a set of relational tables must exist. The
EVMON_FORMAT_UE_TO_TABLES procedure creates the relational tables automatically, as follows:
• The procedure parses the event monitor XML schema file to find the <db2-mon:createStmt>
elements. Each element contains a complete CREATE TABLE statement.
• The procedure extracts and runs the CREATE TABLE statements.
The <db2-mon:createStmt> is a child element of the existing <db2-xdb:table> element. Only
the EVMON_FORMAT_UE_TO_TABLES procedure recognizes and uses this element. All other
procedures that parse the XML schema file, such as the XSR objects, ignore this element.
Do not qualify the table name within the <db2-mon:createStmt>.
XML schema files from release to release
The default XML schema files provided by each event monitor always reflects the XML schema for the
current release. So, when you run EVMON_FORMAT_UE_TO_TABLES (or
EVMON_FORMAT_UE_TO_XML), the output reflects the monitor elements defined for that event
monitor in that release. The next section describes what happens if the schema files for the event
monitors happen to change over time. Understanding the impact of these changes is important if you
create tables using the EVMON_FORMAT_UE_TO_TABLES procedure, and then apply a fix pack or
upgrade to a new release.
Examples
• “Example 1: Using default parameters” on page 407
• “Example 2: Attempting to use tables under a different schema” on page 407
• “Example 3: Attempting to use tables under a different schema” on page 408
• “Example 4: Using the RECREATE_FORCE option” on page 408
• “Example 5: Picking up new elements in a fix pack update” on page 408
• “Example 6: Picking up new elements in a release update” on page 409
• “Example 7: Using the previous relational tables on a release update” on page 409
• “Example 8: Using the UPGRADE_TABLES and PRUNE_UE_TABLE options” on page 409
EVMON_FORMAT_UE_TO_TABLES (
'UOW', NULL, NULL, NULL, NULL, NULL, NULL, -1,
'SELECT * FROM UOWUE
WHERE service_subclass_name = 'STUDENTS'
ORDER BY event_id, event_timestamp')
EVMON_FORMAT_UE_TO_TABLES (
'UOW', NULL, NULL, NULL, 'Paul', NULL, NULL, -1,
'SELECT * FROM UOWTBLE
ORDER BY event_timestamp')
EVMON_FORMAT_UE_TO_TABLES (
'UOW', 'Paul', NULL, NULL, NULL, NULL, NULL, -1,
'SELECT * FROM UOWTBL
ORDER BY event_timestamp')
EVMON_FORMAT_UE_TO_TABLES (
'UOW', NULL, NULL, NULL, NULL, 'MYSPACE', 'RECREATE_FORCE', -1,
'SELECT * FROM UOWTBL
ORDER BY event_timestamp')
EVMON_FORMAT_UE_TO_TABLES (
'LOCKING', NULL, NULL, NULL, NULL, NULL, 'RECREATE_ONERROR', -1,
'SELECT * FROM LOCK
ORDER BY event_timestamp')
EVMON_FORMAT_UE_TO_TABLES (
'LOCKING', NULL, NULL, NULL, NULL, NULL, 'RECREATE_ONERROR', -1,
'SELECT * FROM LOCK
ORDER BY event_timestamp')
EVMON_FORMAT_UE_TO_TABLES (
'LOCKING', NULL, 'EVMON_LOCKING_SCHEMA_SQL11010', NULL, NULL, NULL, NULL, -1,
'SELECT * FROM LOCK
ORDER BY event_timestamp')
EVMON_FORMAT_UE_TO_TABLES (
'UOW', NULL, 'EVMON_UOW_SCHEMA_SQL10050', NULL, NULL, NULL,
'UPGRADE_TABLES;PRUNE_UE_TABLE', -1,
'SELECT * FROM UOWTABLE
ORDER BY event_timestamp')
Note: In this example, the value 'EVMON_UOW_SCHEMA_SQL10050' must be specified for the
xsrobjectname parameter, since 'EVMON_UOW_SCHEMA_SQL10050' is the name of the XSR object that
was used in the most recent release where EVMON_FORMAT_UE_TO_TABLES was run to create relational
tables from a UE table.
Information returned
There is no output from the procedure except the SQLCA. The SQLCA indicates the completion status. The
possible SQLCODES are:
0
All events were successfully inserted into the relational tables.
16278
One or more events were not inserted into the relational tables. The tokens within the SQLCA contain
the total number of documents that were attempted and the total number of documents that
succeeded decomposition.
Syntax
EVMON_FORMAT_UE_TO_XML ( options , FOR EACH ROW OF (
fullselect-statement ) )
Authorization
EXECUTE privilege on the EVMON_FORMAT_UE_TO_XML function.
Examples
Example 1: Query all events from the unformatted event table "MYLOCKS".
Example 2: Query all events of type "LOCKWAIT" that have occurred in the last 5 hours from the
unformatted event table "LOCK".
Example 3: Get all events that belong to workload "PAYROLL" that occurred in the last 32 hours from the
unformatted event table "UOW". Write the result to a file if any document is greater than 100 MB.
Example 4: Query all unit of work events from the "UOWEVMON" table, and use the XMLTABLE table
function to present the UOW ID, UOW start and stop times, and the user ID for the person who issued the
unit of work.
Information returned
num_evmons_evaluated , num_evmons_to_upgrade ,
num_evmons_upgraded )
Procedure parameters
evmon_name
An input argument of type VARCHAR(128) that specifies the name of the event monitor for which
existing table definitions are to be upgraded. The event monitor target type must be table or
unformatted event table. If evmon_name is specified, any evmon_type argument is ignored.
The name may be a pattern-expression similar to that used in the LIKE predicate which means it can
include underscore (_) or percent (%) characters as wild card characters. For more information about
the LIKE predicate, see LIKE predicate. If the pattern-expression needs to include either the
underscore or the percent character, the escape option is used to specify a character to precede
either the underscore or the percent character in the pattern.
If evmon_name is not provided or set to NULL, all event monitors with table or unformatted event
table output targets will be processed, subject to criteria supplied by the other input parameters.
evmon_type
An input argument of type VARCHAR(128) that specifies the type of event monitor for which existing
table definitions are to be upgraded. The type specified must be one of the values in the TYPE column
of SYSCAT.EVENTS. Refer to SYSCAT.EVENTS catalog view for details. Any event monitor for this
event type and having target type of table or unformatted event table will be evaluated for upgrading.
If evmon_type is specified, evmon_name must be NULL. If evmon_type is not provided or set to NULL,
all types of event monitors will be evaluated, subject to the criteria supplied by the other input
parameters.
options
An input argument of type CLOB(8K) that enables you to specify one or more event monitor upgrade
settings. This parameter defaults to NULL. Settings are specified as name value pairs using the
format:
Each setting can be specified a maximum of one time. Setting names are case sensitive. The setting
values are case insensitive unless otherwise noted. The available setting name tags are as follows.
• '<tbspaceName>value</tbspaceName>'
Specifies the name of a table space into which any new groups are to be created. This value is case
sensitive. If this is not specified and an event monitor's current target tables are all in the same
table space then any new table will be created in that same table space (so that all tables are in the
same table space). Otherwise the algorithm for picking a table space as described for the "IN"
clause for "CREATE EVENT MONITOR" is used (see CREATE EVENT MONITOR statement).
• '<createNewGroups>value</createNewGroups>'
Specifies whether or not new groups are to be created. The value can be either "yes" or "no". If not
specified it defaults to "yes" and any new group will be created for an event monitor being
upgraded.
• '<verbose>value</verbose>'
Specifies whether or not to return diagnostics from the stored procedure as a result set. The value
can be either "yes" or "no". If not specified it defaults to "yes" and diagnostics are return in the
Authorization
DBADM authority is required to execute the function.
Usage notes
• If evmon_name and evmon_type are both NULL, then the stored procedure will scan the SYSCAT.
EVENTTABLES catalog table and check each TABLE and UE Table event monitor to see if it's target
tables require upgrading.
• The VERSIONNUMBER column of SYSCAT.EVENTMONITORS contains the version, release, and
modification level in which the event monitor was created or last upgraded. An event monitor target
table is considered to require upgrading if columns were added or modified between the
VERSIONNUMBER and the current release. That is, only changes made between these releases will be
taken into consideration.
– During database upgrade if the VERSIONNUMBER column is not filled in it will be filled with the
release number from which the event monitor is being upgraded.
– If evmon_upgrade_tables processes an event monitor and that event monitor requires no changes
then VERSIONNUMBER is updated to the current level. This makes it easy to see which event
monitors have been processed.
• If evmon_type is specified then the stored procedure will scan the SYSCAT.EVENTTABLES catalog table
and check each event monitor that records that event type to see if it's target tables require upgrading.
If an event monitor can record more than one event type and one of its types is selected for upgrading
Example
A user created the following event monitors in Db2 Version 10.5:
create event monitor lock for locking write to unformatted event table
create event monitor act for activities write to table control (in actspace),
activity (in actspace), activitystmt (in actspace), activityvals (in actspace),
activitymetrics (in actspace)
create event monitor stat for statistics write to table
create event monitor conn for connections write to table
After upgrading the database to the current release they upgrade all the event monitor tables using the
following command:
If instead they only wanted to upgrade act, they could use this command:
Alternatively they could choose to upgrade only the activities event monitors by using this command:
Information Returned
Table 89 on page 416 describes the information returned in the result set if you choose to have it created.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Syntax
MON_CAPTURE_ACTIVITY_IN_PROGRESS ( application_handle , uow_id ,
activity_id )
Procedure parameters
If you do not specify all of the following parameters, no activity is found, and an SQL0171N error with
SQLSTATE 42815 is returned.
application_handle
An input argument of type BIGINT that specifies the handle of the application whose activity
information is to be captured.
uow_id
An input argument of type INTEGER that specifies the unit of work ID of the activity whose
information is to be captured.
activity_id
An input argument of type INTEGER that specifies the activity ID that uniquely identifies the activity
within the unit of work whose information is to be captured.
Usage notes
• If there is no active activities event monitor, an SQL1633W error with SQLSTATE 01H53 is returned.
• Activity information is collected only on the coordinator member for the activity.
Example
Assume that a user complains that stored procedure MYSCHEMA.MYSLOWSTP seems to be running
slower than usual. The administrator wants to investigate the cause of the slowdown. Investigating while
the stored procedure is running is not practical, so the administrator decides to capture information about
the stored procedure activity and all of the activities nested within it.
CALL MON_CAPTURE_ACTIVITY_IN_PROGRESS(1,2,3)
After the procedure is completed, the administrator can use the following table function to find out where
the activity spent its time. The function retrieves the information from the DB2ACTIVITIES event monitor.
MON_COLLECT_STATS procedure - Collect and reset statistics for workload management objects and
operating system resources
The MON_COLLECT_STATS procedure gathers or resets statistics for service classes, workloads, work
classes, threshold queues, and operating system resources.
If there is an active statistics event monitor, the MON_COLLECT_STATS procedure writes the statistics it
collects to the statistics event monitor.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_COLLECT_STATS ( )
wait , statistics_timestamp
Routine parameters
wait
An optional input argument of type CHAR that specifies whether this procedure returns immediately
after initiating a statistics collection and reset. If 'Y' is specified, then the procedure will not return
until all statistics have been written and flushed to the statistics event monitor tables. Otherwise, the
procedure will return immediately after initiating a statistics collection and reset.
statistics_timestamp
An optional output argument of type TIMESTAMP that returns the timestamp value for the beginning
of the statistics collection.
Usage notes
The MON_COLLECT_STATS procedure performs the same collection operation (send statistics to the
active statistics event monitor) and reset operation that occur automatically on the interval defined by the
wlm_collect_int database configuration parameter.
If you call the procedure while another collection and reset request is in progress (for example, while
another invocation of the procedure is running or automatic collection is occurring), SQL1632W with
SQLSTATE 01H53 is returned, and your new request is ignored.
In asynchronous mode, the MON_COLLECT_STATS procedure only starts the collection and reset
process. 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 occur, the call to the
MON_COLLECT_STATS procedure (which is itself an activity) is counted in the statistics for either the prior
collection interval or the new collection interval that has just started.
In synchronous mode, the MON_COLLECT_STATS procedure does not return until the statistics collection
is complete and all statistics are written to the tables of any active statistics event monitors. The
timestamp at which the statistics collection began is returned via the statistics_timestamp output
parameter.
Examples
1. Call MON_COLLECT_STATS to initiate statistics collection and reset.
CALL MON_COLLECT_STATS()
Return Status = 0
2. Call MON_COLLECT_STATS to collect and reset statistics, and return only when data has been written
to statistics event monitor tables.
3. Call MON_COLLECT_STATS to collect and reset statistics while another call is in progress.
CALL MON_COLLECT_STATS()
SQL1632W The collect and reset statistics request was ignored because
another collect and reset statistics request is already in progress.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_FORMAT_LOCK_NAME ( lockname )
Information returned
Not all elements that make up the specified lock name are returned; only those key-value pairs that are
relevant are returned.
Examples
The internal lock name is returned in a variety of situations, such as being written to the db2diag log
files, or as the value of the lock_name monitor element. The following example shows how to use the
MON_FORMAT_LOCK_NAME table function to find out further information about the lock, in this case
with a lock name of 0000000E00000000000B00C152.
5 record(s) selected.
MON_FORMAT_XML_COMPONENT
_TIMES_BY_ROW - Get formatted row-based component times
The MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW table function returns formatted row-based
output for the component times contained in an XML metrics document.
Syntax
MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW ( xmldoc )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Routine parameters
xmldoc
An input argument of type BLOB(8M) that contains an XML document with either a system_metrics or
activity_metrics element. XML documents with these elements can be obtained from the following
sources:
• Returned by one of the MON_GET_*_DETAILS table functions.
• From the metrics column output by statistics and activity event monitors.
• From the formatted output of the unit of work, or package cache event monitors.
Information returned
XML documents that contain an element of type system_metrics are generated from the following
interfaces:
• MON_GET_CONNECTION_DETAILS
• MON_GET_SERVICE_SUBCLASS_DETAILS
• MON_GET_UNIT_OF_WORK_DETAILS
• MON_GET_WORKLOAD_DETAILS
• DETAILS_XML column from a STATISTICS event monitor
• METRICS column produced by EVMON_FORMAT_UE_TO_TABLES for the UNIT OF WORK event monitor
• XMLREPORT column of EVMON_FORMAT_UE_TO_XML for the UNIT OF WORK event monitor
See Table 93 on page 424 for the types of metrics and their parent metrics that are returned from the
XML document in this case:
Table 93. Metric names returned by MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW for XML documents containing a system_metrics
element type
XML documents that contain an element of type activity_metrics are generated from the following
interfaces:
• MON_GET_ACTIVITY_DETAILS
• MON_GET_PKG_CACHE_STMT_DETAILS
• DETAILS_XML column from an ACTIVITY event monitor
• METRICS column produced by EVMON_FORMAT_UE_TO_TABLES for the PACKAGE CACHE event
monitor
• XMLREPORT column of EVMON_FORMAT_UE_TO_XML for the PACKAGE CACHE event monitor
See Table 94 on page 425 for the types of metrics and their parent metrics that are returned from the
XML document in this case:
Table 94. Metric names returned by MON_FORMAT_XML_COMPONENT_TIMES_BY_ROW for XML documents containing an activity_metrics
element type
Example
The following example returns the breakdown of component times within the database manager for
service subclasses, which shows both the total time spent in any given component, as well as the amount
of time that was actually spent processing, rather than waiting, in a component.
9 record(s) selected.
9 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_FORMAT_XML_METRICS_BY_ROW ( xmldoc )
Routine parameters
xmldoc
An input argument of type BLOB(8M) that contains an XML document with either a system_metrics or
activity_metrics element. XML documents with these elements can be obtained from the following
sources:
• Returned by one of the MON_GET_*_DETAILS table functions.
• From the metrics column output by statistics and activity event monitors.
• From the formatted output of the unit of work, or package cache event monitors.
Information returned
XML documents that contain an element of type system_metrics are generated from the following
interfaces:
• MON_GET_CONNECTION_DETAILS
• MON_GET_SERVICE_SUBCLASS_DETAILS
• MON_GET_UNIT_OF_WORK_DETAILS
• MON_GET_WORKLOAD_DETAILS
Table 96. Metric names returned by MON_FORMAT_XML_METRICS_BY_ROW for XML documents containing a
system_metrics element type
Metric Name Description of metric or Monitor element
ACT_ABORTED_TOTAL act_aborted_total - Total aborted activities
ACT_COMPLETED_TOTAL act_completed_total - Total completed activities
ACT_REJECTED_TOTAL act_rejected_total - Total rejected activities
ACT_RQSTS_TOTAL act_rqsts_total - Total activity requests
AGENT_WAIT_TIME agent_wait_time - Agent wait time
AGENT_WAITS_TOTAL agent_waits_total - Total agent waits
APP_ACT_ABORTED_TOTAL app_act_aborted_total - Total failed external coordinator
activities
APP_ACT_COMPLETED_TOTAL app_act_completed_total - Total successful external coordinator
activities
APP_ACT_REJECTED_TOTAL app_act_rejected_total - Total rejected external coordinator
activities
APP_RQSTS_COMPLETED_TOTAL app_rqsts_completed_total - Total application requests
completed
AUDIT_EVENTS_TOTAL audit_events_total - Total audit events
AUDIT_FILE_WRITE_WAIT_TIME audit_file_write_wait_time - Audit file write wait time
AUDIT_FILE_WRITES_TOTAL audit_file_writes_total - Total audit files written
AUDIT_SUBSYSTEM_WAIT_TIME audit_subsystem_wait_time - Audit subsystem wait time
AUDIT_SUBSYSTEM_WAITS_TOTAL audit_subsystem_waits_total - Total audit subsystem waits
CAT_CACHE_INSERTS cat_cache_inserts - Catalog cache inserts
CAT_CACHE_LOOKUPS cat_cache_lookups - Catalog cache lookups
CF_WAIT_TIME cf_wait_time - cluster caching facility wait time
CF_WAITS cf_waits - Number of cluster caching facility waits
CLIENT_IDLE_WAIT_TIME client_idle_wait_time - Client idle wait time
COL_VECTOR_CONSUMER_OVERFLOWS col_vector_consumer_overflows - Columnar vector consumer
overflows monitor element.
COMM_EXIT_WAIT_TIME comm_exit_wait_time - Communication buffer exit wait time
monitor element
COMM_EXIT_WAITS comm_exit_waits - Communication buffer exit number of waits
monitor element
DEADLOCKS deadlocks - Deadlocks detected
DIAGLOG_WRITE_WAIT_TIME diaglog_write_wait_time - Diagnostic log file write wait time
DIAGLOG_WRITES_TOTAL diaglog_writes_total - Total diagnostic log file writes
XML documents that contain an element of type activity_metrics are generated from the following
interfaces:
Table 97. Metric names returned by MON_FORMAT_XML_METRICS_BY_ROW for XML documents containing an
activity_metrics element type
Metric Name Description or Monitor element
AUDIT_EVENTS_TOTAL audit_events_total - Total audit events
AUDIT_FILE_WRITE_WAIT_TIME audit_file_write_wait_time - Audit file write wait time
AUDIT_FILE_WRITES_TOTAL audit_file_writes_total - Total audit files written
AUDIT_SUBSYSTEM_WAIT_TIME audit_subsystem_wait_time - Audit subsystem wait time
AUDIT_SUBSYSTEM_WAITS_TOTAL audit_subsystem_waits_total - Total audit subsystem waits
CF_WAIT_TIME cf_wait_time - cluster caching facility wait time
CF_WAITS cf_waits - Number of cluster caching facility waits
COORD_STMT_EXEC_TIME coord_stmt_exec_time - Execution time for statement by coordinator
agent
DEADLOCKS deadlocks - Deadlocks detected
DIAGLOG_WRITE_WAIT_TIME diaglog_write_wait_time - Diagnostic log file write wait time
DIAGLOG_WRITES_TOTAL diaglog_writes_total - Total diagnostic log file writes
DIRECT_READ_REQS direct_read_reqs - Direct read requests
DIRECT_READ_TIME direct_read_time - Direct read time
DIRECT_READS direct_reads - Direct reads from database
DIRECT_WRITE_REQS direct_write_reqs - Direct write requests
DIRECT_WRITE_TIME direct_write_time - Direct write time
DIRECT_WRITES direct_writes - Direct writes to database
DISABLED_PEDS disabled_peds - Disabled partial early distincts
EVMON_WAIT_TIME evmon_wait_time - Event monitor wait time
EVMON_WAITS_TOTAL evmon_waits_total - Event monitor total waits
FCM_MESSAGE_RECV_VOLUME fcm_message_recv_volume - FCM message received volume
FCM_MESSAGE_RECV_WAIT_TIME fcm_message_recv_wait_time - FCM message received wait time
FCM_MESSAGE_RECVS_TOTAL fcm_message_recvs_total - Total FCM message receives
FCM_MESSAGE_SEND_VOLUME fcm_message_send_volume - FCM message send volume
FCM_MESSAGE_SEND_WAIT_TIME fcm_message_send_wait_time - FCM message send wait time
FCM_MESSAGE_SENDS_TOTAL fcm_message_sends_total - Total FCM message sends
FCM_RECV_VOLUME fcm_recv_volume - FCM received volume
Example
This example shows how to call the MON_FORMAT_XML_METRICS _BY_ROW table function to return
row-based formatted information from the XML document produced by the
MON_GET_WORKLOAD_DETAILS table function.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Syntax
MON_FORMAT_XML_TIMES_BY_ROW ( xmldoc )
Routine parameters
xmldoc
An input argument of type BLOB(8M) that contains an XML document with either a system_metrics or
activity_metrics element. XML documents with these elements can be obtained from the following
sources:
• Returned by one of the MON_GET_*_DETAILS table functions.
• From the metrics column output by statistics and activity event monitors.
• From the formatted output of the unit of work, or package cache event monitors.
Information returned
XML documents that contain an element of type system_metrics are generated from the following
interfaces:
• MON_GET_CONNECTION_DETAILS
• MON_GET_SERVICE_SUBCLASS_DETAILS
• MON_GET_UNIT_OF_WORK_DETAILS
• MON_GET_WORKLOAD_DETAILS
• DETAILS_XML column from a STATISTICS event monitor
• METRICS column produced by EVMON_FORMAT_UE_TO_TABLES for the UNIT OF WORK event monitor
• XMLREPORT column of EVMON_FORMAT_UE_TO_XML for the UNIT OF WORK event monitor
See Table 99 on page 444 for the types of metrics and their parent metrics that are returned from the
XML document in this case:
Table 99. Metric names returned by MON_FORMAT_XML_TIMES_BY_ROW for XML documents containing a
system_metrics element type
Metric Name Parent Metric Name Description of metric or Monitor element
AGENT_WAIT_TIME TOTAL_WAIT_TIME agent_wait_time - Agent wait time
XML documents that contain an element of type activity_metrics are generated from the following
interfaces:
• MON_GET_ACTIVITY_DETAILS
• MON_GET_PKG_CACHE_STMT_DETAILS
• DETAILS_XML column from an ACTIVITY event monitor
• METRICS column produced by EVMON_FORMAT_UE_TO_TABLES for the PACKAGE CACHE event
monitor
• XMLREPORT column of EVMON_FORMAT_UE_TO_XML for the PACKAGE CACHE event monitor
See Table 100 on page 447 for the types of metrics and their parent metrics that are returned from the
XML document in this case:
Table 100. Metric names returned by MON_FORMAT_XML_TIMES_BY_ROW for XML documents containing an
activity_metrics element type
Metric Name Parent Metric Name Description or Monitor element
AUDIT_FILE_WRITE_WAIT TOTAL_ACT_WAIT_TIME audit_file_write_wait_time - Audit file write wait
_TIME time
AUDIT_SUBSYSTEM_WAIT TOTAL_ACT_WAIT_TIME audit_subsystem_wait_time - Audit subsystem
_TIME wait time
CF_WAIT_TIME TOTAL_ACT_WAIT_TIME cf_wait_time - cluster caching facility wait time
DIAGLOG_WRITE_WAIT TOTAL_ACT_WAIT_TIME diaglog_write_wait_time - Diagnostic log file write
_TIME wait time
DIRECT_READ_TIME TOTAL_ACT_WAIT_TIME direct_read_time - Direct read time
DIRECT_WRITE_TIME TOTAL_ACT_WAIT_TIME direct_write_time - Direct write time
EVMON_WAIT_TIME TOTAL_ACT_WAIT_TIME evmon_wait_time - Event monitor wait time
FCM_MESSAGE_RECV_WAIT FCM_RECV_WAIT_TIME fcm_message_recv_wait_time - FCM message
_TIME received wait time
FCM_MESSAGE_SEND_WAIT FCM_SEND_WAIT_TIME fcm_message_send_wait_time - FCM message
_TIME send wait time
FCM_RECV_WAIT_TIME TOTAL_ACT_WAIT_TIME fcm_recv_wait_time - FCM received wait time
FCM_SEND_WAIT_TIME TOTAL_ACT_WAIT_TIME fcm_send_wait_time - FCM send wait time
Syntax
MON_FORMAT_XML_WAIT_TIMES_BY_ROW ( xmldoc )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
This example shows how to call the MON_FORMAT_XML_WAIT_TIMES_BY_ROW table function to return
formatted row-based output from the XML document produced by the MON_GET_WORKLOAD_DETAILS
table function. The output shows the metrics and their values for each workload.
Information returned
XML documents that contain an element of type system_metrics are generated from the following
interfaces:
XML documents that contain an element of type activity_metrics are generated from the following
interfaces:
• MON_GET_ACTIVITY_DETAILS
• MON_GET_PKG_CACHE_STMT_DETAILS
• DETAILS_XML column from an ACTIVITY event monitor
• METRICS column produced by EVMON_FORMAT_UE_TO_TABLES for the PACKAGE CACHE event
monitor
• XMLREPORT column of EVMON_FORMAT_UE_TO_XML for the PACKAGE CACHE event monitor
See Table 103 on page 452 for the types of metrics and their parent metrics that are returned from the
XML document in this case:
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Syntax
MON_GET_ACTIVITY ( application_handle , member )
Routine parameters
application_handle
An input argument of type BIGINT that specifies an application handle for which a list of activities is to
be returned. If the argument is null, the data is retrieved for all the applications in the database.
member
An input argument of type INTEGER that specifies a valid member number in the same instance as the
currently connected database. Specify -1 for the current member, or -2 for all active members. If the
null value is specified, -1 is set implicitly.
Information returned
Table 104. Information returned by the MON_GET_ACTIVITY routine
Examples
Activities currently running with a known application handle
After you identify the application handle, you can look up all the activities currently running in this
application. For example, suppose that an administrator wants to list the activities of an application
whose application handle, determined by using the LIST APPLICATIONS command, is 1. The
administrator runs the following query:
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_ACTIVITY_DETAILS ( application_handle , uow_id , activity_id
, member )
Routine parameters
application_handle
An input argument of type BIGINT that specifies a valid application handle. If the argument is null, no
rows are returned from this function, and an SQL0171N error is returned.
Information returned
The following example shows the structure of the XML document that is returned in the DETAILS column.
For the full schema, see sqllib/misc/DB2MonRoutines.xsd. This document uses the following XML
non-primitive type definitions:
Usage notes
The MON_GET_ACTIVITY_DETAILS function provides maximum flexibility for formatting output because
it returns detailed information for a single activity as an XML document. The XML output includes both
descriptive information (for example, statement text) and metrics. The output can be parsed directly by
an XML parser, or it can be converted to relational format by the XMLTABLE function as shown in the
example.
The metrics reported through this function (for example, CPU usage) are rolled up to the activity
periodically during the lifetime of the activity. Therefore, the values reported by this table function reflect
the current state of the system at the time of the most recent rollup.
Activity metrics are controlled through the COLLECT ACTIVITY METRICS clause on workloads, or the
mon_act_metrics database configuration parameter at the database level. Metrics are collected if the
connection that submits the activity is associated with a workload or database for which activity metrics
are enabled. If activity metrics are not collected for an activity, all metrics are reported as 0.
The MON_GET_ACTIVITY_DETAILS table function returns one row of data for each member on which the
activity exists. No aggregation across members is performed for the metrics. However, aggregation can be
achieved through SQL queries.
The schema for the XML document that is returned in the DETAILS column is available in the file sqllib/
misc/DB2MonRoutines.xsd. Further details can be found in the file sqllib/misc/
DB2MonCommon.xsd.
SELECT application_handle,
activity_id,
uow_id,
local_start_time
FROM TABLE(
WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES(
cast(NULL as bigint), -1)
) AS T
2 record(s) selected.
2. Then use the MON_GET_ACTIVITY_DETAILS table function to view the percentage of time that the
activity has spent waiting.
SELECT actmetrics.application_handle,
actmetrics.activity_id,
actmetrics.uow_id,
varchar(actmetrics.stmt_text, 50) as stmt_text,
actmetrics.total_act_time,
actmetrics.total_act_wait_time,
CASE WHEN actmetrics.total_act_time > 0
THEN DEC((
FLOAT(actmetrics.total_act_wait_time) /
FLOAT(actmetrics.total_act_time)) * 100, 5, 2)
ELSE NULL
END AS PERCENTAGE_WAIT_TIME
FROM TABLE(MON_GET_ACTIVITY_DETAILS(7, 2, 1, -2)) AS ACTDETAILS,
XMLTABLE (XMLNAMESPACES( DEFAULT 'http://www.ibm.com/xmlns/prod/db2/mon'),
'$actmetrics/db2_activity_details'
PASSING XMLPARSE(DOCUMENT ACTDETAILS.DETAILS) as "actmetrics"
COLUMNS "APPLICATION_HANDLE" INTEGER PATH 'application_handle',
"ACTIVITY_ID" INTEGER PATH 'activity_id',
"UOW_ID" INTEGER PATH 'uow_id',
"STMT_TEXT" VARCHAR(1024) PATH 'stmt_text',
"TOTAL_ACT_TIME" INTEGER PATH 'activity_metrics/total_act_time',
"TOTAL_ACT_WAIT_TIME" INTEGER PATH 'activity_metrics/total_act_wait_time'
) AS ACTMETRICS;
1 record(s) selected.
Use the MON_GET_ACTIVITY_DETAILS table function to create a query that captures information
about all the activities currently running on a system.
• Example 1: Run the following command using the command line processor (CLP)
WITH A1 AS
(SELECT * FROM TABLE(wlm_get_workload_occurrence_activities(null, -1))
WHERE activity_id > 0 )
SELECT A1.application_handle,
A1.activity_id,
A1.uow_id,
total_act_time,
total_act_wait_time,
varchar(actmetrics.stmt_text, 50) AS stmt_text FROM A1,
TABLE(MON_GET_ACTIVITY_DETAILS(A1.application_handle, A1.uow_id,A1.activity_id, -1))
AS ACTDETAILS,
XMLTABLE (XMLNAMESPACES( DEFAULT 'http://www.ibm.com/xmlns/prod/db2/mon'),
'$actmetrics/db2_activity_details'
PASSING XMLPARSE(DOCUMENT ACTDETAILS.DETAILS) AS "actmetrics"
COLUMNS "STMT_TEXT" VARCHAR(1024) PATH 'stmt_text',
"TOTAL_ACT_TIME" INTEGER PATH 'activity_metrics/total_act_time',
"TOTAL_ACT_WAIT_TIME" INTEGER PATH 'activity_metrics/total_act_wait_time' )
AS ACTMETRICS
... STMT_TEXT
... -------------------------------------------------
... select name from sysibm.systables
... select * from sysibm.systables
... with A1 as (select * from table(wlm_get_workload_o
_occurrence_" has been truncated. SQLSTATE=01004
MON_GET_AGENT table function - List agents, fenced mode processes, and system entities for the
database
The MON_GET_AGENT function returns a list of all agents, fenced mode processes (db2fmp processes),
and system entities for the database. The list can be filtered to show information for a specified member,
service class, or application.
The system entities are non-agent threads and processes, such as page cleaners and prefetchers.
Refer to Table 107 on page 495 for a complete list of information that can be returned.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_AGENT ( service_superclass_name , service_subclass_name ,
application_handle , member )
Routine parameters
service_superclass_name
An input argument of type VARCHAR(128) that specifies the name of a service superclass in the
currently connected database. If the argument is null or an empty string, data is retrieved for all the
superclasses in the database.
service_subclass_name
An input argument of type VARCHAR(128) that refers to a specific subclass within a superclass. If the
argument is null or an empty string, data is retrieved for all the subclasses in the database.
application_handle
An input argument of type BIGINT that specifies the application handle for which agent information is
to be returned. If the argument is null, data is retrieved for all applications in the database. An
application handle of 0 returns the system entities only.
member
An input argument of type INTEGER that specifies the member number in the same instance as the
currently connected database. Specify -1 for the current database member, or -2 for all active
database members. If a null value is specified, -1 is set implicitly.
Information returned
EVENT_TYPE VARCHAR (32) Type of event last processed by this agent. The possible
values are as follows:
• ACQUIRE
• PROCESS
• WAIT
See Table 108 on page 500 for more information about
possible values for this column.
EVENT_STATE VARCHAR (32) State of the event last processed by this agent. The
possible values are as follows:
• EXECUTING
• IDLE
See Table 108 on page 500 for more information about
possible values for this column.
REQUEST_ID VARCHAR (64) Request ID. This value is unique only in combination with
the value of application_handle. You can use this
combination to distinguish between one request that is
taking a long time and multiple requests; for example, to
distinguish between one long fetch and multiple fetches.
– ABP
– CATALOG
– INTERNAL
– REORG
– RUNSTATS
– WLM
• For subagents with a SUBTYPE of OTHER:
– ABP
– APP_RBSVPT
– APP_RELSVPT
– BACKUP
– CLOSE
– EXTERNAL_RBSVPT
– EVMON
– FORCE
– FORCE_ALL
– INTERNAL number, where number is the value of the
internal constant
– INTERRUPT
– NOOP (if there is no request)
– QP
– REDISTRIBUTE
– STMT_RBSVPT
– STOP_USING
– UPDATE_DBM_CFG
– WLM
AGENT_STATE_LAST TIMESTAMP The last time that the event, being processed by the agent,
_UPDATE_TIME was changed. The event currently processed by the agent
is identified by the EVENT_TYPE, EVENT_OBJECT, and
EVENT_STATE columns.
Table 108. Possible combinations for EVENT_STATE, EVENT_TYPE, EVENT_OBJECT, and EVENT_OBJECT_NAME
column values
EVENT_OBJECT
Event EVENT_STATE EVENT_TYPE EVENT_OBJECT _ EVENT_OBJECT
description value value value NAME value _DETAILS value
Acquire lock IDLE ACQUIRE LOCK Lock name NULL
Escalate lock EXECUTING PROCESS LOCK_ESCALATI NULL NULL
ON
Process request EXECUTING PROCESS REQUEST NULL NULL
Wait for a new IDLE WAIT REQUEST NULL NULL
request
Wait for a IDLE WAIT REMOTE_REQUE NULL NULL
request to be ST
processed at a
remote member
Usage notes
The parameters are, in effect, ANDed together. That is, if you specify conflicting input parameters, such as
a service superclass SUP_A and a subclass SUB_B such that SUB_B is not a subclass of SUP_A, no rows
are returned.
Examples
1. The following query returns a list of agents that are associated with application handle 1 for all
database members. You can determine the application handle by using the LIST APPLICATIONS
command or the MON_GET_CONNECTION table function.
The output shows a coordinator agent and a subagent on member 0 and a subagent on member 1
operating on behalf of an activity with UOW ID 1 and activity ID 5. The AGENTTYPE column with a
value of COORDINATOR has a value of FETCH for the REQTYPE column (which indicates the main or
initial request type). This means that the type of request is a fetch request for the coordinator agent.
2. The following query determines which lock an agent is waiting on:
21 record(s) selected.
Using the same query at a later time shows that the WLM threshold has queued an agent:
21 record(s) selected.
In this example, an agent with an AGENT_TID value of 338 represents partition 0; a value of 277
represents partition 1; a value of 278 represents partition 2. All three of these agents are waiting to
send to TQ_ID 3 on all partitions. Sending to all partitions is known as a broadcast. In this case, this
broadcast occurs in subsection ID 2. The agent with an ID of 250 on partition 0 is processing
subsection 0 and is waiting to receive on TQ_ID 1 from any partition. The agent with an ID of 343 is
also waiting to receive on subsection 0 but on TQ_ID 2 from any partition. The agent with IDs 335 and
336 are not waiting on any TQ.
)
, system_appls
Routine parameters
application_handle
An optional input parameter of type BIGINT that specifies a valid application handle in the same
database as the one to which you are currently connected. If the argument is null, locks are retrieved
for all applications that are currently waiting for locks to be acquired.
member
An input parameter of type INTEGER that specifies a valid member in the same instance as the
currently connected database. Specify -1 for the current database member, or -2 for all active
members. If the NULL value is specified, -1 is set.
system_appls
An input parameter of type SMALLINT that specifies whether information for system applications is to
be returned. The following values are valid:
• 0 or NULL: System application information is not returned. NULL is the default if a value for
system_appls is not provided.
• 1: User and system application information is returned.
Authorization
One of the following authorities or privilege is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
The columns that are returned provide information in the following areas:
• The following columns represent details about the lock that the application is currently waiting to
acquire:
LOCK_WAIT_START_TIME, LOCK_NAME, LOCK_OBJECT_TYPE, LOCK_MODE, LOCK_CURRENT_MODE,
LOCK_MODE_REQUESTED, LOCK_STATUS, LOCK_ESCALATION, LOCK_ATTRIBUTES, LOCK_RRIID,
LOCK_COUNT, TBSP_ID, TAB_FILE_ID, SUBSECTION_NUMBER.
• The following columns represent details about the application that is waiting to acquire this lock.
REQ_APPLICATION_HANDLE, REQ_AGENT_TID, REQ_MEMBER, REQ_EXECUTABLE_ID
• The following columns represent details about the application that is currently holding the lock.
HLD_APPLICATION_HANDLE, HLD_MEMBER, ADDITIONAL_DETAILS
Example
In this sample scenario, the MON_GET_APPL_LOCKWAIT table function is used to investigate a hung
application for the session authorization ID USER1.
1. Use the MON_GET_CONNECTION table function to look up the application handle for all connections
with the SESSION_USER value of USER1:
COORD_PARTITION_NUM APPLICATION_HANDLE
------------------------------- ----------------------------
2 131130
1 record(s) selected.
2. Use the MON_GET_AGENT table function to obtain current information about all agents working for
this connection, on all database partitions:
4 record(s) selected.
An event of type ACQUIRE on an event object of type LOCK indicates a lock wait scenario. Now you can
investigate which object is being waited for and which process is holding the lock on it.
3. To determine all locks that the application is waiting for, call the MON_GET_APPL_LOCKWAIT table
function with application handle 131130 and member -2 as input parameters.
SELECT lock_name,
hld_member AS member,
hld_agent_tid as TID,
hld_application_handle AS HLD_APP FROM
TABLE (MON_GET_APPL_LOCKWAIT(131130, -2))
3 record(s) selected.
4. Call the MON_GET_CONNECTION table function to find out more about the application that is holding
the lock (this application has an application handle of 65564).
Syntax
MON_GET_APPLICATION_HANDLE ( )
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
The data type of the result is BIGINT.
Example
The MON_GET_APPLICATION_HANDLE scalar function can be used to pass in the application handle of
the current session into monitoring functions which filter based on the application handle, such that the
session can access its own monitoring information. For example:
ROWS_READ
----------
0
1 record(s) selected.
MON_GET_APPLICATION_ID ( )
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
The data type of the result is VARCHAR(128).
values sysproc.mon_get_application_id()
1
-------------------------------
*LOCAL.amurchis.110831180720
Syntax
MON_GET_AUTO_MAINT_QUEUE ()
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Display the current jobs on the automatic maintenance queue on each partition.
SELECT MEMBER
QUEUE_POSITION,
JOB_STATUS,
JOB_TYPE,
VARCHAR(DB_NAME, 10) AS DB_NAME,
OBJECT_TYPE,
VARCHAR(OBJECT_SCHEMA, 10) AS OBJECT_SCHEMA
VARCHAR(OBJECT_NAME, 10) AS OBJECT_NAME
FROM TABLE(MON_GET_AUTO_MAINT_QUEUE()) AS T
ORDER BY MEMBER, QUEUE_POSITION ASC
OBJECT_NAME
-----------
EMPLOYEE
T1
BLAH
SELECT JOB_STATUS,
JOB_TYPE,
OBJECT_TYPE,
VARCHAR(OBJECT_NAME, 10) AS OBJECT_NAME,
VARCHAR(JOB_DETAILS,60) AS JOB_DETAILS
FROM TABLE(MON_GET_AUTO_MAINT_QUEUE()) AS T
ORDER BY MEMBER, QUEUE_POSITION ASC
JOB_DETAILS
------------------------------------------------------------
REORG INDEXES ALLOW WRITE CLEANUP ALL; RECLAIM EXTENTS
1 record(s) selected.
Usage notes
The MON_GET_AUTO_MAINT_QUEUE table function returns information about all queued and executing
automatic maintenance jobs on all members. Note that there is a separate automatic maintenance queue
per member.
Note: Jobs in the automatic maintenance queue are ordered first by earliest start time (such as start of
next maintenance window where job may run), priority (for entries with same earliest start time) and
queue entry time (for entries with the same earliest start time and priority).
The information returned from MON_GET_AUTO_MAINT_QUEUE supplements the information from the
HEALTH_DB_HIC interface. HEALTH_DB_HIC shows the automatic maintenance status for each table to
which automatic maintenance is applied, as well as the last time the status was updated (such as last
time table was checked to see if maintenance is needed). The MON_GET_AUTO_MAINT_QUEUE interface
provides a drill down for when the state is AUTOMATED, providing details about where the maintenance
job is in the auto maintenance queue, and what other jobs are ahead of the job in the queue.
The MON_GET_AUTO_MAINT_QUEUE table function does not report any automatic maintenance jobs if
automatic maintenance is not enabled.
Information returned
Syntax
MON_GET_AUTO_RUNSTATS_QUEUE ()
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Display all objects that are currently under evaluation by automatic statistics collection in the currently
connected database.
SELECT QUEUE_POSITION,
OBJECT_TYPE,
OBJECT_STATUS,
VARCHAR(OBJECT_SCHEMA, 10) AS OBJECT_SCHEMA,
VARCHAR(OBJECT_NAME, 10) AS OBJECT_NAME
FROM TABLE(MON_GET_AUTO_RUNSTATS_QUEUE()) AS T
ORDER BY QUEUE_POSITION ASC
3 record(s) selected.
Usage notes
The MON_GET_AUTO_RUNSTATS_QUEUE table function returns information about all objects queued for
evaluation by automatic statistics collection in the currently connected database. Objects queued for
evaluation will be examined by automatic statistics collection to determine if a statistics update is
required. When an object is found to require statistics update, a job is submitted to the automatic
maintenance scheduler and evaluation temporarily blocks until the job completes execution. Use the
MON_GET_AUTO_MAINT_QUEUE interface to monitor the progress of the statistics collection job. After
an object has been evaluated by automatic statistics collection is removed from the evaluation queue, it
will not be added to the queue again until the next automatic statistics collection evaluation interval. For a
per-object history of evaluation, refer to the HEALTH_DB_HIC interface.
Each database has a separate automatic statistics collection evaluation queue. The
MON_GET_AUTO_RUNSTATS_QUEUE reports the evaluation queue for the currently connected database.
The list reported by the MON_GET_AUTO_RUNSTATS_QUEUE interface may be empty if there are no
objects currently queued for evaluation by automatic statistics collection. For example, if automatic
statistics collection has processed all the tables that were queued for evaluation in the current evaluation
interval, the list of objects queued for evaluation will be empty until the next evaluation interval.
Automatic statistics collection evaluation intervals occur roughly every two hours.
The list reported by the MON_GET_AUTO_RUNSTATS_QUEUE interface is also empty if automatic
statistics collection is not enabled.
Syntax
MON_GET_BUFFERPOOL ( bp_name , member )
Example
Compute the buffer pool hit ratio.
WITH BPMETRICS AS (
SELECT bp_name,
pool_data_l_reads + pool_temp_data_l_reads +
pool_index_l_reads + pool_temp_index_l_reads +
pool_xda_l_reads + pool_temp_xda_l_reads as logical_reads,
pool_data_p_reads + pool_temp_data_p_reads +
pool_index_p_reads + pool_temp_index_p_reads +
pool_xda_p_reads + pool_temp_xda_p_reads as physical_reads,
member
FROM TABLE(MON_GET_BUFFERPOOL('',-2)) AS METRICS)
SELECT
VARCHAR(bp_name,20) AS bp_name,
logical_reads,
physical_reads,
CASE WHEN logical_reads > 0
THEN DEC((1 - (FLOAT(physical_reads) / FLOAT(logical_reads))) * 100,5,2)
ELSE NULL
END AS HIT_RATIO,
member
FROM BPMETRICS;
5 record(s) selected.
Usage notes
The MON_GET_BUFFERPOOL table function returns one row of data per database buffer pool and per
database member. No aggregation across database members is performed. However, aggregation can be
achieved through SQL queries as shown in the example.
Metrics collected by this function are controlled at the database level by using the mon_obj_metrics
configuration parameter. By default, metrics collection is enabled.
Information returned
Syntax
MON_GET_CF ( id )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
The following query displays information about the group buffer pool size for all cluster caching facilities
on the system. It shows a resize in progress for the group buffer pool. The CURRENT_CF_GBP_SIZE
parameter shows the group buffer pool memory currently in use. The CONFIGURED_CF_GBP_SIZE
parameter shows the group buffer pool memory currently allocated and reserved. The
TARGET_CF_GBP_SIZE parameter shows the group buffer pool dynamic resize target.
The next example returns information about the group buffer pool size for the cluster caching facility that
has the identifier of 128.
Information returned
Syntax
MON_GET_CF_CMD ( id )
Example
The following statement is issued on a Db2 pureScale instance with multiple members and two cluster
caching facilities with identifiers CF15 and CF16:
Usage notes
Data is returned only if you issue this function in a Db2 pureScale environment.
The reported values are provided by the CF and are independent of the instance level for a member or the
number of databases that are active for a member.
The values that are returned in the TOTAL_CF_REQUESTS and TOTAL_CF_CMD_TIME_MICRO columns
are calculated since cluster startup. You cannot reset the values; they are read-only.
You can calculate the average time by dividing the return value of the TOTAL_CF_CMD_TIME_MICRO
column by the number returned by the TOTAL_CF_REQUESTS column.
Information returned
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_CF_WAIT_TIME ( member )
Information returned
Table 117. List of CF commands that are monitored by the MON_GET_CF_WAIT_TIME function
CF Command or alias name Description
DeletePage Delete a page from the CF.
DeletePageList Delete a list of pages from the CF.
DeleteSA Delete an entry from a smart array (SA) in the CF.
DeleteSAList Delete a list of entries from an SA in the CF.
DeregisterPage Deregister a page from the CF.
DeregisterPageList Deregister a list of pages from the CF.
GetAndIncLFS Get and increment the log flush sequence (LFS) number in the
CF.
GetLFS Get an LFS from the CF.
GetLSN Get the log sequence number (LSN) from the CF.
GetNotification Return the commands issued to get notification messages
from the global lock manager (GLM) in the CF.
GetStatus Get the user control structures field from the CF.
Usage notes
Data is returned only if you issue this function in a Db2 pureScale environment.
This table function returns one row of data per command and per member.
The values are provided at the instance level for a member, and are independent of the number of
databases active for a member, because a member is connected to a CF at the instance level.
The values that are returned in the TOTAL_CF_REQUESTS and TOTAL_CF_WAIT_TIME_MICRO return
columns are calculated since cluster startup. You cannot reset the values; they are read-only.
You can calculate the average time by dividing the return value of the TOTAL_CF_WAIT_TIME_MICRO
column by the number returned by the TOTAL_CF_REQUESTS column.
Example
To examine the rate at which page deregistration occurs on a specific CF, which is identified in the
db2nodes.cfg file as number 128, you want to compare values over a specific length of time. To begin,
issue the following statement:
This query returns the initial values for the comparison. Then, wait 10 seconds for the CF to deregister
additional pages.
To get the updated values, issue the following statement:
Finally, calculate the rate at which the CF is deregistrating pages by using the following formula:
(DEREG_RQ2 - DEREG_RQ1)
DEREG_PAGE_RATE = -----------------------
(DEREG_T2 - DEREG_T1)
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Syntax
MON_GET_CONNECTION ( application_handle , member
)
, system_appls
Routine parameters
application_handle
An input parameter of type BIGINT that specifies a specific application handle identifying the
connection for which the metrics are to be returned. If the argument is null, metrics are returned for
all connections
member
An input parameter of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the null value is specified, -1 is set implicitly.
system_appls
An input parameter of data type SMALLINT that specifies whether information for system applications
is returned. The following values are valid:
• 0 or NULL: System application information is not returned. NULL is the default if a value for
system_appls is not provided.
• 1: User and system application information is returned.
Information returned
Usage notes
The metrics returned by the MON_GET_CONNECTION table function represent the accumulation of all
metrics for requests that were submitted by a connection. Metrics are rolled up at unit of work
boundaries, and periodically during the execution of requests. Therefore, the values reported by this table
function reflect the current state of the system at the time of the most recent rollup. Metrics are strictly
increasing in value. To determine the value of a given metric for an interval of time, use the
MON_GET_CONNECTION table function to query the metric at the start and end of the interval, and
compute the difference.
Request metrics are controlled through the COLLECT REQUEST METRICS clause on service superclasses
and the mon_req_metrics database configuration parameter at the database level. Metrics are only
collected for a request if the request is processed by an agent in a service subclass whose parent service
superclass has request metrics enabled, or if request metrics collection is enabled for the entire
database. By default, request metrics are enabled at the database level. If request metrics are disabled at
the database level and for a service superclass, then the metrics reported for each connection that is
mapped to that service superclass will stop increasing (or remain at 0 if request metrics were disabled at
database activation time).
Tip: As a connection can be mapped to more than one service superclass during its lifetime, the metrics
reported through the MON_GET_CONNECTION table function might represent a subset of the metrics for
all requests submitted over the connection. This might occur if metrics collection is disabled for some of
the superclasses that are mapped by the connection.
The MON_GET_CONNECTION table function returns one row of data per connection and per member. No
aggregation across members (for a service class or more), is performed. However, aggregation can be
achieved through SQL queries.
SELECT application_handle,
rows_returned,
tcpip_send_volume
FROM TABLE(MON_GET_CONNECTION(cast(NULL as bigint), -2)) AS t
ORDER BY rows_returned DESC
1 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_CONNECTION_DETAILS ( application_handle , member
)
, system_appls
Routine parameters
application_handle
An input argument of type BIGINT that specifies a specific application handle identifying the
connection for which the metrics are to be returned. If the argument is NULL, metrics are returned for
all connections.
member
An input argument of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the null value is specified, -1 is set implicitly.
system_appls
An input parameter of data type SMALLINT that specifies whether information for system applications
is returned. The following values are valid:
• 0 or NULL: System application information is not returned. NULL is the default if a value for
system_appls is not provided.
Information returned
The following example shows the structure of the XML document that is returned in the DETAILS column.
<xs:simpleType name="db2DbObjectString">
<xs:restriction base="xs:string">
<xs:maxLength value="128"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="db2PartitionNum">
<xs:restriction base="xs:nonNegativeInteger">
<xs:maxInclusive value="999"/>
</xs:restriction>
</xs:simpleType>
Example
Display connections returning the highest volume of data to clients, ordered by rows returned.
SELECT detmetrics.application_handle,
detmetrics.rows_returned,
detmetrics.tcpip_send_volume
FROM TABLE(MON_GET_CONNECTION_DETAILS(CAST(NULL as bigint), -2))
AS CONNMETRICS,
XMLTABLE (XMLNAMESPACES( DEFAULT 'http://www.ibm.com/xmlns/prod/db2/mon'),
'$detmetric/db2_connection' PASSING XMLPARSE(DOCUMENT CONNMETRICS.DETAILS)
as "detmetric"
COLUMNS "APPLICATION_HANDLE" INTEGER PATH 'application_handle',
"ROWS_RETURNED" BIGINT PATH 'system_metrics/rows_returned',
"TCPIP_SEND_VOLUME" BIGINT PATH 'system_metrics/tcpip_send_volume'
) AS DETMETRICS
ORDER BY rows_returned DESC
1 record(s) selected.
Syntax
MON_GET_CONTAINER ( tbsp_name , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Example 1: List containers on all database members that have the highest read time.
CONTAINER_NAME ...
---------------------------------------------------------------------- ...
/home/hotel55/swalkty/swalkty/NODE0000/TEST/T0000000/C0000000.CAT ...
/home/hotel55/swalkty/swalkty/NODE0000/TEST/T0000002/C0000000.LRG ...
/home/hotel55/swalkty/swalkty/NODE0000/TEST/T0000001/C0000000.TMP ...
3 record(s) selected.
CONTAINER_NAME
----------------------------------------------------------------------
0 record(s) selected.
CONTAINER_NAME ...
----------------------------------------------------------------- ...
/home/hotel55/swalkty/swalkty/NODE0000/TEST/T0000000/C0000000.CAT ...
/home/hotel55/swalkty/swalkty/NODE0000/TEST/T0000001/C0000000.TMP ...
/home/hotel55/swalkty/swalkty/NODE0000/TEST/T0000002/C0000000.LRG ...
3 record(s) selected.
Usage notes
The MON_GET_CONTAINER table function returns one row of data per container and per database
member. Data can be returned for all containers in a given table space, or for all containers in the
database. No aggregation across database partitions is performed. However, aggregation can be achieved
through SQL queries.
Metrics collected by this function are controlled at the database level by using the mon_obj_metrics
configuration parameter. By default, metrics collection is enabled.
Information returned
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_DATABASE ( member )
Routine parameters
member
An input parameter of type INTEGER that specifies a valid database member from which the records
should be fetched. Specify -1 or null for the current member, or -2 for information from all active
database members. An active database member is a database that is available for connection and use
by applications.
Information returned
Table 122. Information returned by the MON_GET_DATABASE routine
Examples
1. Determine the activation time, activation state, total connections, and connection high water mark for
the current database on all members:
2. Get the explicit hierarchical locking state for the database from all database members.
SELECT MEMBER,
DATA_SHARING_REMOTE_LOCKWAIT_COUNT AS DSRL_COUNT,
DATA_SHARING_REMOTE_LOCKWAIT_TIME AS DSRL_TIME
FROM TABLE(MON_GET_DATABASE(-2))
The query returns the following output, indicating that one table exited from a "NOT_SHARED" state,
taking approximately 10 seconds to do so.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_DATABASE_DETAILS ( member )
Routine parameters
member
An input parameter of type INTEGER that specifies a valid database member from which the records
should be fetched. Specify -1 or null for the current member, or -2 for information from all active
database members. An active database member a database that is available for connection and use
by applications.
Information returned
appl_section lookups xs:nonNegativeInteger appl_section lookups - SQL workspace access count monitor
element
pool_read_time xs:long pool_read_time - Total buffer pool physical read time monitor
element
pool_write_time xs:long pool_write_time - Total buffer pool physical write time monitor
element
pool_xda_l_reads xs:long pool_xda_l_reads - Buffer pool XDA data logical reads monitor
element
pool_xda_writes xs:long pool_xda_writes - Buffer pool XDA data writes monitor element
Example
Retrieve information about rows_read, num_locks_waiting, total_cpu_time, and direct_reads, at the
database level on the current member.
Syntax
MON_GET_EXTENDED_LATCH_WAIT ( member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Syntax
MON_GET_EXTENT_MOVEMENT_STATUS ( tbsp_name , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Retrieve all information about the current extent progress for all table spaces:
5 record(s) selected.
Information returned
Syntax
MON_GET_FCM ( member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
To retrieve information about the fast communication manager message buffers on all members:
3 record(s) selected.
Information returned
Note: The metrics provided by this table function apply to all members on a given host machine. All
members on a given host machine share the same set of buffers and channels. This means that the
individual metrics will usually be the same for each member on given host machine. However, each
member executes independently and the metrics might differ slightly as the resource numbers change in
between the sampling on different members.
Syntax
MON_GET_FCM_CONNECTION_LIST ( member )
Authorization
One of the following authorities is required to execute the routine:
Information returned
MON_GET_GROUP_BUFFERPOOL
The MON_GET_GROUP_BUFFERPOOL table function returns statistics about the group buffer pool (GBP).
Syntax
MON_GET_GROUP_BUFFERPOOL ( member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
If the group buffer pool (GBP) does not have sufficient space when attempting to register a page or write
a page to the GBP, a GBP_FULL error occurs.
The following example returns the number of times the GBP_FULL error is encountered from all members.
NUM_GBP_FULL
------------
123
1 record(s) selected.
If the value of NUM_GBP_FULL increases by more than one per minute, then the current size of the GBP
likely does not meet your needs. In this case, increase the size of the GBP with the command:
For this command, the value of <new_size> grows the group buffer pool to a size sufficient to slow or
stop the increasing number of GBP_FULL errors.
Information Returned
MON_GET_HADR table function - Returns high availability disaster recovery (HADR) monitoring
information
This function returns high availability disaster recovery (HADR) monitoring information.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
Syntax
MON_GET_HADR ( member )
Routine parameters
member
An input argument of type INTEGER that specifies a member number. Returned rows represent log
streams being processed by the member. Specify -1 for the current database member, or -2 for all
active database members. If the null value is specified, -1 is set implicitly.
Information returned
Usage notes
HADR pair view
Certain fields are applicable to primary or standby only. For example, PEER_WAIT_LIMIT is applicable
only to primary, STANDBY_RECV_BUF_SIZE, STANDBY_SPOOL_LIMIT,
READS_ON_STANDBY_ENABLED are applicable only to standby. When this kind of information is
reported, the database currently in the role is used (which may be the remote database), rather than
the local database. For example, PEER_WAIT_LIMIT seen on a standby database is the value
Examples
STANDBY_MEMBER_HOST
--------------------
hostS1.ibm.com
hostS2.ibm.com
hostS3.ibm.com
3 record(s) selected.
Query is issued to a primary database with 3 standbys in which 3 rows are returned. Each row
represents a primary-standby log shipping channel. The HADR_ROLE column represents the role of
the database to which the query is issued. Therefore it is PRIMARY on all rows.
2. SELECT HADR_ROLE, STANDBY_ID, HADR_STATE, varchar(PRIMARY_MEMBER_HOST ,20)
as PRIMARY_MEMBER_HOST, varchar(STANDBY_MEMBER_HOST ,20)
as STANDBY_MEMBER_HOST from table(MON_GET_HADR(NULL))
STANDBY_MEMBER_HOST
--------------------
hostS1.ibm.com
1 record(s) selected.
Query is issued to a standby database with reads on standby enabled. Standby only knows about its
own primary. Only one row is returned even if the standby is part of a multiple standby system.
STANDBY_ID is always zero when query is issued to a standby.
3. The following example is for HADR in a Db2 pureScale environment only. The environment for this
example has three member clusters. On the primary, member 0 is assisting member 1. Standby
member 0 is the replay member.
• For log stream ID 2, the HADR information for log stream 2 is output:
• When specifying -2 as member ID, HADR information on all log streams is reported. For assisted
remote catchup, only the record from the assisting member is returned, and HADR_FLAGS indicates
that it is in an assisted remote catchup state.
Syntax
MON_GET_INDEX ( tabschema , tabname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Identify the most frequently used indexes on the DMEXT002.TABLE1 table, since the last database
activation:
6 record(s) selected.
Usage notes
The MON_GET_INDEX table function returns one row of data per index, and per database member. If
partitioned indexes are being used, one row is returned for each index partition per database member. No
aggregation across database members is performed. However, aggregation can be achieved through SQL
queries as shown in the previous example.
Metrics will only be returned for indexes on tables that have been accessed since the database was
activated. All counters represent data since the current database activation. For example, the
pseudo_empty_pages counter is the number of pages that have been identified as pseudo empty since the
database was activated. it is not the current number of pseudo empty pages in the index.
The metrics returned by this function are collected at two levels. Some metrics are always collected,
while the collection of other metrics is controlled at the database level by using the mon_obj_metrics
Information returned
Syntax
MON_GET_INDEX_USAGE_LIST (usagelistschema , usagelistname, member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Example
Return the usage list USL_MON_IND1 from all database members
DATA_PARTITION_ID
-----------------
-
-
EXECUTABLE_ID
-------------------------------------------------------------------
x'0100000000000000490000000000000000000000020020110706093802577065'
x'01000000000000004B0000000000000000000000020020110706093825981548'
NUM_REF_WITH_METRICS OBJECT_INDEX_L_READSOBJECT_INDEX_P_READS
-------------------- ----------------------------------------
1 1 0
1 1 0
OBJECT_INDEX_GBP_L_READS OBJECT_INDEX_GBP_P_READS
------------------------ ------------------------
0 0
0 0
OBJECT_INDEX_GBP_INVALID_PAGES OBJECT_INDEX_LBP_PAGES_FOUND
------------------------------ ----------------------------
0 0
0 0
2 record(s) selected.
Usage notes
Each row returned by this function represents the total number of times (num_references) a unique
section (DML statement only, executable ID) has referenced a particular object during a particular time
interval (monitor interval ID) since being added to the list. The statistics collected for this row represents
the total aggregated value across these executions during this time interval.
Use the num_ref_with_metrics column instead of the num_references column when computing averages,
since the num_references column counts all executions of the section, regardless of whether or not the
execution of the section contributed to the metrics that are reported.
Metrics collected by this function are controlled at the database level by using the mon_obj_metrics
configuration parameter. By default, metrics collection is enabled.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_INSTANCE ( member )
Routine parameters
member
An input parameter of type INTEGER that specifies a valid database member from which the records
should be fetched. Specify -1 or null for the current member, or -2 for information from all active
database members. An active database member is a database that is available for connection and use
by applications.
Information returned
DB2START_TIME TOTAL_CONNECTIONS
-------------------------- --------------------
2012-09-11-15.39.05.000000 2
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_LATCH ( search_args , member )
Routine parameters
search_args
An input parameter of type CLOB(1 K) that represents a list of key-value pairs. If the list is empty or
NULL, all latches from the specified member are returned. Otherwise, all latches that match all of the
conditions that are represented by the list of key-value pairs are returned. A key-value pair must
follow this format:
• A key is a string that represents an opening tag. An opening tag consists of an angle bracket,
followed by the key name, followed by a closing angle bracket. Spaces are not allowed. An example
of an opening tag is <application_handle>
• The value is placed after the opening tag
• A closing tag consists of an opening angle bracket, followed by a forward slash, followed by the key
name, followed by a closing angle bracket. Spaces are not allowed. An example of a closing tag is </
application_handle>
The following example shows of a full key-value pair:
'<application_handle>123</application_handle>'
All keys are case-sensitive and can be specified one time each in the search_args parameter.
The order of the keys does not matter.
SQLCODE -171 is returned for an invalid key-value pair.
An implicit AND operator exists between different keys.
CLOB('<application_handle>123</application_handle>')
CLOB('<application_handle>145</application_handle>')
latch_name
Returns a list of all latches that match the specified latch name. The value is specified as a string,
whose maximum length is 256 characters. For example:
CLOB('<latch_name>SQLO_LT_SQLB_PTBL__pool_table_latch</latch_name>')
edu_id
Returns a list of all latches that match the specified edu_id. For example:
CLOB('<edu_id>28</edu_id>')
latch_status
Returns a list of all latches in the specified status. The value that is specified can be one of the
following characters:
H
Latches that are held.
W
Latches that are waiting.
C
Latches that are contested. A contested latch occurs when an application acquires a latch,
then another application waits for this latch.
For example:
CLOB('<latch_status>W</latch_status>')
The following examples demonstrate how to use key-value pairs in the search_args parameter.
1. Search for all latches:
CLOB( '' )
CLOB('<application_handle>123</application_handle>
<latch_name>SQLO_LT_SQLB_PTBL__pool_table_latch</latch_name>' )
CLOB('<latch_status>C</latch_status>')
member
An input argument of type INTEGER that specifies the member from which data is returned.
Specify -1 for the current member. Specify -2 for all active members.
Example
In this sample scenario, the MON_GET_LATCH table functions are used to get all latch information in
databases with connections, on all members.
1. Call the MON_GET_LATCH table function to retrieve all latch information in databases with
connections, on all members:
9 record(s) selected.
2. Call the MON_GET_LATCH table function to determine the latches that are contested.
5 record(s) selected.
3. The previous output shows two latches that are contested by applications. To retrieve only the
SQLO_LT_SQLB_PTBL__pool_table_latch latch, specify the latch_name value in the search_args
argument to return the applications that are contesting this latch.
3 record(s) selected.
CLOB('<application_handle>123</application_handle>
<lock_object_type>Table:Row</lock_object_type>
<lock_mode>S:X</lock_mode>')
CLOB('<application_handle>145</application_handle>')
• lock_name
Returns a list of all locks that match the specified lock name. Only a single occurrence of the key
value can be specified. The value is specified as a string of maximum length 32. For example:
CLOB('<lock_name>00030005000000000280000452</lock_name>')
• lock_object_type
Returns a list of all locks that match the specified lock object type. Multiple occurrences of the key
value can be specified (to a maximum of 5). Each value (case insensitive) must be separated by a
colon (:) and is specified as a string of a maximum length of 32 characters. For example:
CLOB('<lock_object_type>Table:Chunk:Plan</lock_object_type>')
For a list of possible input values, see "lock_object_type - Lock object type waited on monitor
element".
• lock_mode
Returns a list of all locks that match the specified lock mode. Multiple occurrences of the key value
can be specified (to a maximum of 5). Each value (case insensitive) is separated by a colon (:) and is
specified as a string of maximum length 3. For example:
CLOB('<lock_mode>IS:IN:U</lock_mode>')
For a list of possible input values, see "lock_mode - Lock mode monitor element".
• lock_status
Returns a list of all locks in the specified status. Only a single occurrence of the key value can be
specified. The value is specified as a character.
CLOB('<lock_status>W</lock_status>')
For a list of possible input values, see "lock_status - Lock status monitor element".
• table_schema
Returns a list of all locks that are qualified by the specified schema name. The table_name key must
also be specified. Only a single occurrence of the key value can be specified. The value is specified
as a string of maximum length 128.
CLOB('<table_schema>USER1</table_schema>
<table_name>INVENTORY</table_name>')
• table_name
Returns a list of all locks that reference the specified table. The table_schema key must also be
specified. Only a single occurrence of the key value can be specified. The value is specified as a
string of maximum length 128. For example:
CLOB('<table_schema>USER1</table_schema>
<table_name>INVENTORY</table_name>')
The following examples demonstrate how to use key-value pairs in the search_args parameter.
CLOB('<lock_object_type>Table:Row</lock_object_type>')
2. To search for all locks that application handle 123 is holding or waiting to acquire that reference
table T1, and were created by user USER1:
CLOB('<application_handle>123</application_handle>
<table_schema>USER1</table_schema>
<table_name>T1</table_name>')
3. To search for all TABLE, ROW, and BUFFERPOOL locks that are currently held in Shared mode:
CLOB('<lock_mode>S</lock_mode>
<lock_status>G</lock_status>
<lock_object_type>Table:Row:Bufferpool</lock_object_type>')
member
An input argument of type INTEGER that specifies from which member the data is returned. Specify
-1 for the current member, and -2 for all active members.
Authorization
One of the following authorities or privilege is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
In this sample scenario, the MON_GET_LOCKS and MON_GET_APPL_LOCKWAIT table functions are used
to investigate the locking situation in the current connected database, on all members.
1. Call the MON_GET_APPL_LOCKWAIT table function to determine all the locks that are waiting to be
acquired in the current connected database, on all members:
SELECT lock_name,
hld_member,
lock_status,
hld_application_handle FROM
TABLE (MON_GET_APPL_LOCKWAIT(NULL, -2))
3 record(s) selected.
The records that show HLD_MEMBER is -2 indicate that the lock 0x00030005000000000280000452
is being held at a remote member.
2. Call the MON_GET_LOCKS table function to determine the holder of the lock, by specifying the lock
name, 0x00030005000000000280000452, as the search argument:
SELECT lock_name,
member,
4 record(s) selected.
To find out more about the application holding the lock, you can call the
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES or
WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES table functions.
Information returned
MON_GET_MEMORY_POOL - get
memory pool information
The MON_GET_MEMORY_POOL table function retrieves metrics from the memory pools contained within
a memory set.
Syntax
MON_GET_MEMORY_POOL ( memory_set_type , db_name , member )
db_name
An input argument of type VARCHAR(128) that specifies a valid database name in the same instance
as the currently connected database when calling this function.
The database must have a directory entry type of either "INDIRECT" or "HOME", as returned by a LIST
DATABASE DIRECTORY command. The database must be active. Alternatively, the
CURRENT_SERVER special register can be specified to retrieve metrics from the currently connected
database. The register value contains the actual name of the database, not an alias.
If the argument is NULL or an empty string, metrics are taken from all active databases in the
instance. This input argument applies only to database level memory sets.
member
An input argument of type INTEGER that specifies from which member the data is returned. Specify -1
for the current database member, or -2 for all active members. If the NULL value is specified, -1 is set
implicitly.
Example
Example 1: Retrieve memory set metrics for the current instance and the currently connected database.
21 record(s) selected
Usage notes
In a partitioned database environment, the fast communication manager (FCM) memory set is allocated
per host; all members on this host machine share this set. The MON_GET_MEMORY_POOL function
retrieves data from each member. Since the FCM memory set is shared among all members on the host,
the metrics reported for FCM memory for each member on the host represent information about the same
shared memory set. For this reason, when examining metrics for FCM memory, examine the data for each
unique host. For hosts with multiple members, use data from only one member on that host, as the
metrics for FCM memory represent the aggregated total for all members on the given host.
MON_GET_MEMORY_SET - get
memory set information
The MON_GET_MEMORY_SET table function retrieves metrics from the allocated memory sets, both at
the instance level, and for all active databases within the instance.
Syntax
MON_GET_MEMORY_SET ( memory_set_type , db_name , member )
db_name
An input argument of type VARCHAR(128) that specifies a valid database name in the same instance
as the currently connected database when calling this function.
The database must have a directory entry type of either "INDIRECT" or "HOME", as returned by a LIST
DATABASE DIRECTORY command. The database must be active. Alternatively, the
CURRENT_SERVER special register can be specified to retrieve metrics from the currently connected
database. The register value contains the actual name of the database, not an alias.
If the argument is NULL or an empty string, metrics are taken from all active databases in the
instance. This input argument applies only to database level memory sets.
member
An input argument of type INTEGER that specifies from which member the data is returned. Specify -1
for the current database member, or -2 for all active members. If the NULL value is specified, -1 is set
implicitly.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Example 1: Retrieve memory set metrics for the current instance and the currently connected database.
5 record(s) selected
Information returned
Syntax
MON_GET_PAGE_ACCESS_INFO ( tabschema , tabname , member )
Example
This example returns page reclaim counts for all tables in schema BASETAB on the currently connected
member. It shows that applications are waiting for pages for table TABLE1 (an example of what could
cause this situation is updating different rows on the same page from two different members).
ORDER BY NAME;
Usage notes
The MON_GET_PAGE_ACCESS_INFO table function returns one or two rows of data for each table per
member that it gathers data from. One row of data shows information for INDEX pages. The second row
shows information for DATA pages. No aggregation across members is performed.
Information returned
Syntax
MON_GET_PKG_CACHE_STMT ( section_type , executable_id ,
search_args , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Routine parameters
section_type
An optional input argument (either "D" or "S") of type CHAR(1) that specifies information type for the
returned statement. If the argument is NULL or the empty string, information is returned for all SQL
statements. Not case-sensitive: "D" stands for dynamic; "S" for static.
executable_id
An optional input argument of type VARCHAR (32) for bit data that specifies a unique section of the
database package cache. If a null value is specified, information is returned for all SQL statements.
When the executable_id is specified, the section_type argument is ignored. For example, if an
executable_id is specified for a dynamic statement, the dynamic statement details will be returned by
this table function even if section_type is specified as static ("S").
search_args
An optional input parameter of type CLOB(1K), that allows you to specify one or more optional search
argument strings. For example:
'<modified_within>5</modified_within><update_boundary_time>myPkgEvmon
</update_boundary_time>'
Information returned
Usage notes
The MON_GET_PKG_CACHE_STMT table function returns a point-in-time view of both static and dynamic
SQL statements in the database package cache. This allows you to examine the aggregated metrics for a
particular SQL statement, allowing you to quickly determine the reasons for poor query performance. The
metrics returned are aggregates of the metrics gathered during each execution of the statement.
It also allows you to compare the behavior of an individual cached section, relative to the other
statements, to assist in identifying the most expensive section or statements (in terms of the execution
costs).
The activity metrics reported by this function are rolled up to the global package cache at the end of the
execution of the activity.
Metrics collection for the execution of any statement is controlled through the COLLECT ACTIVITY
METRICS clause on workloads, or the mon_act_metrics database configuration parameter at the
database level. Metrics are only collected for executions of the statement if the statement was submitted
by a connection associated with a workload or database for which activity metrics are enabled. The
num_exec_with_metrics element returned by the MON_GET_PKG_CACHE_STMT function indicates
how many executions of the statement have had metrics collected and have contributed to the aggregate
metrics reported. If no metrics are collected for any execution of the statement, then the
num_exec_with_metrics element is 0 and all metric values are returned as 0.
The output that is returned by MON_GET_PKG_CACHE_STMT is not directly comparable to the output
obtained through the dynamic SQL snapshot. The following are differences between the two interfaces:
• MON_GET_PKG_CACHE_STMT reports data per individual section in the cache, whereas the dynamic
SQL snapshot aggregates all sections for the statement. Therefore, MON_GET_PKG_CACHE provides
more granularity. It distinguishes statements that have separate entries in the cache because of a
combination of environment differences.
• MON_GET_PKG_CACHE_STMT captures the metrics during query plan execution. The dynamic SQL
snapshot might include some of the work that is done when the section is loaded, depending on how
the statement is run from the application side.
Depending on the package cache size and contents, retrieving the full information available from the
MON_GET_PKG_CACHE_STMT routine might require a substantial amount of memory. To reduce the
Example
List all the dynamic SQL statements from the database package cache ordered by the average CPU time.
5 record(s) selected.
With the earlier output, you can use the executable_id to find out the details about the most expensive
statement (in terms of the average CPU time):
STMT_TEXT
-------------------------------------------------------------------------------------------
SELECT * FROM EMPLOYEE
As another example, assume a user named Alex has a connection associated to workload A which has the
COLLECT ACTIVITY METRICS set. Another user, Brent, is associated to workload B that has the COLLECT
ACTIVITY METRICS set to NONE. In addition, the database mon_act_metrics configuration parameter
is set to NONE. When Brent executes the query:
all metrics are returned as 0 and the value of num_exec_with_metrics is also 0. Then Alex executes
the same statement afterwards, but the metrics are collected this time for the execution of the statement
and num_exec_with_metrics increments. So, after Brent and Alex execute that statement, the result
of this query:
shows that the SELECT statement ran twice and one of the execution times had the activity metrics
collected.
1 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_PKG_CACHE_STMT_DETAILS ( section_type , executable_id ,
search_args , member )
Routine parameters
section_type
An optional input argument (either "D" or "S") of type CHAR(1) that specifies information type for the
returned statement. If the argument is NULL or an empty string, information is returned for all SQL
statements. Not case sensitive: D stands for dynamic; S for static.
executable_id
An optional input argument of type VARCHAR (32) for bit data that specifies a unique section of the
database package cache. If a null value is specified, information is returned for all SQL statements.
When the executable_id is specified, the section_type argument is ignored. For example, if an
executable_id is specified for a dynamic statement, the dynamic statement details will be returned by
this table function even if section_type is specified as static ("S").
search_args
An optional input parameter of type CLOB(1K), that allows you to specify one or more optional search
argument strings. For example:
'<modified_within>5</modified_within><update_boundary_time>myPkgEvmon
</update_boundary_time>'
Information returned
Usage notes
The metrics returned by this function represent the accumulation of all metrics for statements in the
package cache. Statement metrics are rolled up to the package cache upon activity completion.
The schema for the XML document that is returned in the DETAILS column is available in the file sqllib/
misc/DB2MonRoutines.xsd. Further details can be found in the file sqllib/misc/
DB2MonCommon.xsd.
Examples
The first example demonstrates how to examine the package cache and select the 10 statements that
have read and returned the largest number of rows. Additionally, the results show the cumulative amount
of time spent executing each of these statements (in the STMT_EXEC_TIME output column).
10 record(s) selected.
The second example shows, for dynamic SQL statements that have waited on a lock while executing, the
number of executions, number of lock waits and average time spent per lock wait. The output shows
values accumulated over the lifetime of the package cache entries, but restricts information to
statements that have executed within the last minute (by setting the modified_within argument tag to 1).
The query excludes the statement details (stmt_text and comp_env_desc data) because they are not
required and they are computationally expensive to report (by setting the stmt_details argument tag to
false).
Authorization
At least one of the following authorizations is required:
Syntax
MON_GET_QUEUE_STATS ( predicate , ,
domain
, )
threshold_name threshold_id
Routine parameters
predicate
An input argument of type VARCHAR(27) that specifies for which queue or queues statistics are to be
retrieved:
CONCDBC
Retrieve statistics for the concurrent database coordinator activities threshold queue.
DBCONN
Retrieve statistics for the total database member connections threshold queue.
SCCONN
Retrieve statistics for the total service class member connections threshold queue.
If this argument is null or an empty string, statistics are retrieved for all queues that meet the other
criteria.
The specified value corresponds to the value in the THRESHOLDPREDICATE column of the
SYSCAT.THRESHOLDS view.
domain
An input argument of type VARCHAR(18) that specifies a threshold domain:
DB
Database.
SB
Service subclass.
SP
Service superclass.
WA
Work action set.
If this argument is null or an empty string, statistics are retrieved for all queues that meet the other
criteria.
The specified value corresponds to the value in the DOMAIN column of the SYSCAT.THRESHOLDS
view.
Information returned
Usage notes
The function does not aggregate data across members (for one or more queues). However, you can use
SQL queries to aggregate data, as shown in the example.
Examples
• The following query displays the basic statistics for all the queues on a system, across all members:
Sample output:
Syntax
MON_GET_REBALANCE_STATUS ( tbsp_name , dbpartitionnum )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
List all active rebalance operations on the database and display their current state and progress.
select
varchar(tbsp_name, 30) as tbsp_name,
dbpartitionnum,
member,
rebalancer_mode,
rebalancer_status,
rebalancer_extents_remaining,
rebalancer_extents_processed,
rebalancer_start_time
from table(mon_get_rebalance_status(NULL,-2)) as t
REBALANCER_START_TIME
--------------------------
2011-12-01-12.08.16.000000
1 record(s) selected.
Usage notes
The MON_GET_REBALANCE_STATUS table function only returns data for a table space if a rebalance is in
progress. Otherwise, no data is returned.
Information returned
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
• DBADM authority
, routine_name , member )
Routine parameters
routine_type
An input parameter of type CHAR(2) that specifies the type of routine or compiled trigger for which
data is returned:
• "P" for a procedure
• "SP" for the specific name of a procedure
• "F" for a compiled function
• "SF" for the specific name of a compiled function
• "T" for a compiled trigger
• "C" for a dynamically prepared compound SQL statement or an anonymous block in PL/SQL
If the "P","F","T" or "C" routine type is specified and no input name is specified, all routines of the
given type will be returned. If the routine type is "SP" or "SF", the specific name of the routine must be
provided.
If the routine type is an empty string, NULL, or blanks, all routines of all types are returned.
routine_schema
An input parameter of type VARCHAR(128) that specifies the schema for the routine or trigger. For
dynamically prepared compound SQL statements or anonymous blocks, the schema can be
determined using the MON_GET_SECTION_ROUTINES table function. Use NULL or an empty string to
return the routines and triggers in all schemas. This parameter is case sensitive.
routine_module_name
An input parameter of type VARCHAR(128) that specifies the name of the module for the input
routine, if applicable. Use NULL or an empty string to return the routines in all modules. This
parameter is case sensitive.
routine_name
An input parameter of type VARCHAR(128) that specifies the name of the routine. If the input
parameter is "SP" or "SF", the specific name of the routine must be provided. For dynamically
prepared compound SQL statements or anonymous blocks, the name can be determined using the
MON_GET_SECTION_ROUTINES table function. Use NULL or an empty string to return all routines
that match the other input parameters. This parameter is case sensitive.
member
An input parameter of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the NULL value is specified, -1 is implicitly set.
Information returned
Table 144. Information returned for MON_GET_ROUTINE
Description or corresponding monitor
Column name Data type element
ROUTINE_TYPE CHAR(1) routine_type - Routine type monitor element
ROUTINE_SCHEMA VARCHAR(128) routine_schema - Routine schema monitor
element
Usage notes
Use the MON_GET_ROUTINE table function to identify the most expensive routines on the database
server.
This table function returns one row of metrics for each routine or trigger and each member that matches
the input arguments. Input argument values are complementary. Metrics returned are aggregates of all
executions of the routine on that member. No aggregation across members is performed. However, an
aggregation across members is possible through SQL queries (as shown in the Examples section). If a
routine executes subroutines, the work done in the subroutines is included in the metrics of the parent
routine.
Routine monitoring data collection must be explicitly enabled using the mon_rtn_data database
configuration parameter. If this configuration parameter is set to NONE, no information is returned.
The counters and time-spent monitor elements returned by this table function are controlled with the
COLLECT REQUEST METRICS clause on service classes and the mon_req_metrics database
configuration parameter at the database level. If neither control is enabled, the counters and time-spent
monitor elements reported are 0.
When the package for a dynamically prepared compound SQL statements is removed from the package
cache, information for this routine is no longer reported by MON_GET_ROUTINE function. Similarly, when
a routine or trigger is dropped, information about the routine or trigger is no longer reported.
Any routines that were not executed during the previous 24 hour period are pruned from memory and not
returned.
returns
7 record(s) selected.
4. List aggregate monitor data for all procedures named PROC1 in schema TEST.
5. List aggregate monitor data for overloaded procedure PROC1 with specific name PROC1_OVERLOAD in
schema TEST.
6. List aggregate monitor data for the anonymous block with executable id
x'0100000000000000520100000000000001000000010020120822205618607103'.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
• DBADM authority
Syntax
MON_GET_ROUTINE_DETAILS ( routine_type , routine_schema ,
Routine parameters
routine_type
An input parameter of type CHAR(2) that specifies the type of routine or compiled trigger for which
data is returned:
• "P" for a procedure
• "SP" for the specific name of a procedure
• "F" for a compiled function
• "SF" for the specific name of a compiled function
• "T" for a compiled trigger
• "C" for an anonymous block
If the "P", "F"', "T", or "C" routine type is specified and no input name is specified, all routines of the
given type will be returned. If the routine type is "SP" or "SF", the specific name of the routine must be
provided.
All routines of all types will be returned if the routine type is NULL, an empty string, or blanks.
routine_schema
An input parameter of type VARCHAR(128) that specifies the schema for the routine or trigger. For
dynamically prepared compound SQL statements and PL/SQL anonymous blocks, the schema can be
determined using the MON_GET_SECTION_ROUTINES table function. Use NULL or an empty string to
return the routines and triggers in all schemas. This parameter is case sensitive.
routine_module_name
An input parameter of type VARCHAR(128) that specifies the name of the module for the input
routine, if applicable. Use NULL or an empty string to return the routines in all modules. This
parameter is case sensitive.
routine_name
An input parameter of type VARCHAR(128) that specifies the name of the routine. If the input
parameter is "SP" or "SF", the specific name of the routine should be provided. For dynamically
prepared compound SQL statements and PL/SQL anonymous blocks, the name can be determined
using the MON_GET_SECTION_ROUTINES table function. Use NULL or an empty string to return all
routines matching the other input parameters. This parameter is case sensitive.
member
An input parameter of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the NULL value is specified, -1 is implicitly set.
The following example shows the structure of the XML document that is returned in the DETAILS column.
Usage notes
Use the MON_GET_ROUTINE_DETAILS table function to identify the most expensive routines on the
database server.
This table function returns one row of metrics for each routine or trigger and each member that matches
the input arguments. Input argument values are complementary. Metrics returned are aggregates of all
executions of the routine on that member. No aggregation across members is performed. However, an
aggregation across members is possible through SQL queries (as shown in the Examples section). If a
routine executes subroutines, the work done in the subroutines is included in the metrics of the parent
routine.
Routine monitoring data collection must be explicitly enabled using the mon_rtn_data database
configuration parameter. If this configuration parameter is set to NONE, no information is returned.
The counters and time-spent monitor elements returned by this table function are controlled with the
COLLECT REQUEST METRICS clause on service classes and the mon_req_metrics database
configuration parameter at the database level. If neither control is enabled, the counters and time-spent
monitor elements reported are 0.
When the package for a dynamically prepared compound SQL statement has been removed from the
package cache, information for this routine will no longer be reported by MON_GET_ROUTINE_DETAILS
function. Similarly, when a routine is dropped, information about the routine is no longer be reported.
Any routines that were not executed during the previous 24 hour period are pruned from memory and not
returned.
The schema for the XML document that is returned in the DETAILS column is available in the file sqllib/
misc/DB2MonRoutines.xsd. Further details can be found in the file sqllib/misc/
DB2MonCommon.xsd.
returns
5 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
• DBADM authority
Syntax
MON_GET_ROUTINE_EXEC_LIST ( routine_type , routine_schema ,
Routine parameters
routine_type
An input parameter of type CHAR(2) that specifies the type of routine or compiled trigger for which
data is be returned:
• "P" for a procedure
• "SP" for the specific name of a procedure
• "F" for a compiled function
• "SF" for the specific name of a compiled function
• "T" for a compiled trigger
• "C" for a dynamically prepared compound SQL statement in SQL PL or an anonymous block in
PL/SQL
Information returned
Examples
1. List all the statements executed by function TEST.X.
returns
TEXT
---------------------------------------------
WITH PID_VALUES (WIDEBAND,ENGN_TEMP) AS SEL
insert into GSO_LOGS values(8.7, 145, 1.406)
call SYSIBMSUBROUTINE.TEST_66613_1157394573()
3 record(s) selected.
2. List all the statements in procedure TEST.PROC1 by the percentage of coordinator statement
execution time that they are consuming.
returns
PERCENT_EXEC_TIME STMT_TEXT
------------------ ---------------------------------------------
10 SELECT WAFR, MPHX64, ENGN_RPM FROM KB28_LOGS
3 SELECT ( ENGN_TQ * ENGN_RPM )/5252 AS HP FRO
2 record(s) selected.
Syntax
MON_GET_RTS_RQST ()
Authorization
You require one of the following types of authorization to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
The following query displays all pending and currently queued or executing real-time statistics requests:
SELECT MEMBER,
QUEUE_POSITION,
REQUEST_STATUS,
REQUEST_TYPE,
OBJECT_TYPE,
VARCHAR(OBJECT_SCHEMA, 10) AS SCHEMA,
VARCHAR(OBJECT_NAME, 10) AS NAME
FROM TABLE(MON_GET_RTS_RQST()) AS T
ORDER BY MEMBER, QUEUE_POSITION ASC
7 record(s) selected.
Usage notes
The MON_GET_RTS_RQST table function returns information about all real-time statistics requests that
are pending on all members. The queue for processing real-time statistics requests exists only on a single
member.
The MON_GET_RTS_RQST table function does not report any real-time statistics requests if real-time
statistics collection is not enabled.
MON_GET_SECTION table function - Get a copy of a section from the package cache
The MON_GET_SECTION table function returns a copy of a section for a dynamic or static SQL statement
from the package cache. The section that is returned can be saved for future analysis. For example, when
you investigate a plan change for a statement, the saved section can be passed as input to the
EXPLAIN_FROM_DATA stored procedure to examine the previous access plan.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
Syntax
MON_GET_SECTION ( executable_id )
Routine parameters
executable_id
An input argument of type VARCHAR (32) FOR BIT DATA that specifies a unique section in the
database package cache.
The routine searches the package cache on all members for the section. For static SQL, the catalogs
are searched if the section is no longer in the package cache.
If a null or invalid value is specified, SQL0171 is returned.
Information returned
Example
Use the following query to retrieve the statement text, statement identifier, plan identifier, and section
information from the compilation environment. Information is returned for all statements currently in the
package cache. The information is inserted into a table called REPOSITORY_SECTIONS.
INSERT INTO
REPOSITORY_SECTIONS(STMT_TEXT, STMTID, PLANID,
SEMANTIC_ENV_ID, SECTION_DATA)
SELECT STMT_TEXT, STMTID, PLANID, SEMANTIC_ENV_ID,
( SELECT B.SECTION_ENV
FROM TABLE(MON_GET_SECTION(A.EXECUTABLE_ID)) AS B)
SECTION_DATA
FROM TABLE(MON_GET_PKG_CACHE_STMT(NULL,NULL,NULL,-2)) AS A
You can use this information to build a history of statements that ran. You can use the
EXPLAIN_FROM_DATA stored procedure to examine the access plan for each saved statement by
passing the saved section to the stored procedure.
Syntax
MON_GET_SECTION_OBJECT ( executable_id , object_type ,
Routine parameters
executable_id
An optional input parameter of type VARCHAR(32) FOR BIT DATA that uniquely identifies a section for
which the list of objects is to be returned. If this argument is NULL then information for all sections in
the package cache are returned.
object_type
An optional input parameter of type VARCHAR(16) that identifies the object types to be returned. If
this argument is null or an empty string, then all types of objects are returned. Valid object types are
listed in Table 150 on page 716.
object_schema
An optional input parameter of type VARCHAR(128) that identifies the schema for the objects to be
returned. If this argument is null or an empty string, then objects in all schemas are returned.
object_module
An optional input parameter of type VARCHAR(128) that identifies the module of the objects to be
returned. If this argument is null or an empty string, then objects defined in all modules are returned.
object_name
An optional input parameter of type VARCHAR(128) that identifies the name of the object to be
returned. If this argument is null or an empty string, then objects are not filtered by name.
member
An optional input argument of type SMALLINT that specifies a valid member in the same instance as
the currently connected database when this function is called. Specify -1 for the current database
member or -2 for all active database members. If the null value is specified, -1 is set.
Information returned
Example
As part of your investigation of a poorly performing statement, you want to examine which objects are
used in the access plan for the statement. Assuming the section for the statement is identified by the
executable_id
x'0100000000000000010000000000000000000000020020130726092341206252', you can list the
objects that are accessed by the section with this query:
3 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
• DBADM authority
Syntax
MON_GET_SECTION_ROUTINE ( executable_id )
Information returned
Usage notes
The input section must reside in the package cache.
Objects returned by this function are not necessarily invoked during execution of the input section. For
example, in the following select statement FUNCTION1 is a compiled function:
SELECT CASE WHEN COL1 = 0 THEN FUNCTION1() ELSE NULL END AS T1 FROM TABLE1
FThe MON_GET_SECTION_ROUTINE table function will return a row with the FUNCTION1 function when
executable_id is passed as an argument, identifying the section for this statement. However,
FUNCTION1 will be invoked during execution of the statement only if TABLE1 contains the value 0 for
COL1 in one of its rows.
Examples
1. List all routines that might be executed by the section in the package cache with executable ID
x'0100000000000000520100000000000001000000010020120822205618607103'.
SELECT * FROM
TABLE(MON_GET_SECTION_ROUTINE(
x'0100000000000000520100000000000001000000010020120822205618607103'))
AS T
returns
SELECT * FROM
TABLE(MON_GET_SECTION_ROUTINE(
x'0100000000000000520100000000000001000000010020120822205618607103'))
AS T WHERE ROUTINETYPE = 'T'
returns
3. Find the internal schema and procedure name for an anonymous block with executable ID
x'0100000000000000520100000000000001000000010020120822205618607103'.
returns
Syntax
MON_GET_SERVERLIST ( member )
, member_subset_name
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Usage notes
• The MON_GET_SERVERLIST table function returns one row for each member address cached in a server
list that matches the input arguments. Each row contains connectivity information and relative priority
which enable a remote client to perform workload balancing and automatic client reroute.
• The MEMBER column indicates which member cached the server list information; the SUBSET_ID
column indicates what member subset the server list information was cached for.
Examples
1. Assume a connection to database SAMPLE on member 0, where the database has been accessed by a
remote client. List all server list metrics as cached on this member for this database:
2. Assume a connection to database SAMPLE on member 0 and that the database has been accessed on
both members 0 and 1 by a remote client. List all server list metrics as cached on both members for
this database:
Output results for connection to database SAMPLE on member 0, which is currently active on
members 0 and 1.
3. Assume a connection to the database alias MY_ALIAS exists on member 0 and the database has been
accessed on all members. Assume that the connection has been assigned to the member subset
MY_SUBSET which includes members 0 and 1 and excludes member 2. List the server list metrics for
the member subset MY_SUBSET as cached on member 0.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Syntax
MON_GET_SERVICE_SUBCLASS ( service_superclass_name ,
service_subclass_name , member )
Routine parameters
service_superclass_name
An input argument of type VARCHAR(128) that specifies a valid service superclass name in the
currently connected database when calling this function. If the argument is null or an empty string,
metrics are retrieved for all the superclasses in the database.
service_subclass_name
An input argument of type VARCHAR(128) that specifies a valid service subclass name in the currently
connected database when calling this function. If the argument is null or an empty string, metrics are
retrieved for all the subclasses in the database.
member
An input argument of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the null value is specified, -1 is set implicitly.
Information returned
Note: In the rows returned by this function that describe the default subclass SYSDEFAULTSUBCLASS
under the superclass SYSDEFAULTSYSTEMCLASS, all columns that report metrics have a value of 0.
Usage notes
The metrics returned by the MON_GET_SERVICE_SUBCLASS table function represent the accumulation of
all metrics for requests that have executed under the indicated service subclass. Metrics are rolled up to a
Example
Display the total CPU time used and total number of requests processed for each service class, ordered
by CPU usage.
3 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_SERVICE_SUBCLASS_DETAILS ( service_superclass_name ,
service_subclass_name , member )
Routine parameters
service_superclass_name
An input argument of type VARCHAR(128) that specifies a valid service superclass name in the
currently connected database when calling this function. If the argument is null or an empty string,
metrics are retrieved for all the superclasses in the database.
service_subclass_name
An input argument of type VARCHAR(128) that specifies a valid service subclass name in the currently
connected database when calling this function. If the argument is null or an empty string, metrics are
retrieved for all the subclasses in the database.
member
An input argument of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the null value is specified, -1 is set implicitly.
Information returned
Usage notes
The metrics returned by the MON_GET_SERVICE_SUBCLASS_DETAILS table function represent the
accumulation of all metrics for requests that have executed under the indicated service subclass. This
function is similar to the MON_GET_SERVICE_SUBCLASS table function:
• The MON_GET_SERVICE_SUBCLASS table function returns the most commonly used metrics in a
column based format and is the most performance efficient method of retrieving metrics.
• The MON_GET_SERVICE_SUBCLASS_DETAILS table function returns the entire set of available metrics
in an XML document format, which provides maximum flexibility for formatting output. The XML-based
output can be parsed directly by an XML parser, or it can be converted to relational format by the
XMLTABLE function (see the example).
Metrics are rolled up to a service class on unit of work boundaries, and periodically during the execution
of requests. Therefore, the values reported by this table function reflect the current state of the system at
the time of the most recent rollup. Metrics are strictly increasing in value. To determine the value of a
given metric for an interval of time, use the MON_GET_SERVICE_SUBCLASS_DETAILS table function to
query the metric at the start and end of the interval, and compute the difference.
Request metrics are controlled through the COLLECT REQUEST METRICS clause on service superclasses,
and the mon_req_metrics database configuration parameter at the database level. Metrics are only
collected for a request if the request is processed by an agent in a service subclass whose parent service
superclass has request metrics enabled, or if request metrics collection is enabled for the entire
database. By default request metrics are enabled at the database level. If request metrics are disabled at
the database level and for a service superclass, the metrics reported for each connection mapped to that
service superclass stop increasing (or remain at 0 if request metrics were disabled at database activation
time).
The MON_GET_SERVICE_SUBCLASS_DETAILS table function returns one row of data per service subclass
and per member. No aggregation across service classes (on a member), or across members (for a service
class or more), is performed. However, aggregation can be achieved through SQL queries (see the
example). The input parameters have the effect of being ANDed together. Therefore, if you specify
conflicting input parameters (for example, a superclass name SUPA and subclass name SUBB that is not a
subclass of SUPA), no rows are returned.
In the data returned by this function that describe the default subclass SYSDEFAULTSUBCLASS under the
superclass SYSDEFAULTSYSTEMCLASS, all metrics have a value of 0.
Tip: A request might execute in more than one service subclass. For example, this situation might occur if
a request is mapped from one service subclass to another by using a Workload Manager (WLM) threshold
with a REMAP ACTIVITY action. Although the time spent metrics are updated for each service subclass
under which the request executes, the request counters are incremented for the service subclass where
the request completed. Therefore, you should not analyze the averages of request times for a single
subclass. All subclasses to which an activity can be mapped must be analyzed in conjunction with one
another. For example, if a threshold exists that can map activities from service subclass A to service
subclass B, then when you compute averages of requests, you should aggregate the counters and metrics
for service subclasses A and B, and compute the averages using the aggregates.
Note that the metrics from background EDUs such as prefetchers and page cleaners are not rolled up to
service classes.
The schema for the XML document that is returned in the DETAILS column is available in the file sqllib/
misc/DB2MonRoutines.xsd. Further details can be found in the file sqllib/misc/
DB2MonCommon.xsd.
3 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Syntax
MON_GET_SERVICE_SUBCLASS_STATS ( service_superclass_name ,
service_subclass_name , member )
Routine parameters
service_superclass_name
An input argument of type VARCHAR(128) that specifies the name of a service superclass in the
currently connected database. If the argument is null or an empty string, the data is retrieved for all of
the superclasses in the database.
Information returned
Usage notes
Some statistics are returned only if you set the COLLECT AGGREGATE ACTIVITY DATA and COLLECT
AGGREGATE REQUEST DATA parameters for the corresponding service subclass to a value other than
NONE.
The MON_GET_SERVICE_SUBCLASS_STATS table function returns one row of data per service subclass
and per member. The function does not aggregate data across service classes (on a partition) or across
partitions (for one or more service classes). However, you can use SQL queries to aggregate data.
The parameters are assessed in conjunction with each other. If you specify conflicting input parameters,
no rows are returned. For example, if you specify a superclass named SUPA and a subclass named SUBB
(where SUBB is not a subclass of SUPA), no rows are returned.
Examples
Example 1: Because every activity must be mapped to a database service class before being run, you can
monitor the global state of the system by using the service class statistics table functions and querying all
of the service classes on all members. In the following example, a null value is passed for
service_superclass_name and service_subclass_name to return statistics for all service classes, and the
value -2 is specified for member to return statistics for all members:
The statement returns service class statistics such as average activity lifetime and standard deviation in
seconds, as shown in the following sample output:
By checking the average execution times and numbers of activities in the output of this table function, you
can get a good high-level view of the load on each member for a specific database. Any significant
variations in the high-level gauges returned by this table function might indicate a change in the load on
the system.
Example 3: If an activity uses thresholds with REMAP ACTIVITY TO actions, the activity might spend time
in more than one service class during its lifetime. You can determine how many activities have passed
through a set of service classes by looking at the ACT_REMAPPED_IN and ACT_REMAPPED_OUT
columns, as shown in the following example:
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Routine parameters
service_superclass_name
An input argument of type VARCHAR(128) that specifies a valid service superclass name in the
currently connected database when calling this function. If the argument is null or an empty string,
metrics are retrieved for all the superclasses in the database.
member
An input argument of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the null value is specified, -1 is set implicitly.
Information returned
Usage notes
The metrics returned by the MON_GET_SERVICE_SUPERCLASS table function represent the
accumulation of all metrics for requests that have executed under the indicated service superclass.
Metrics are rolled up to a service class on unit of work boundaries, and periodically during the execution
of requests. Therefore, the values reported by this table function reflect the current state of the system at
the time of the most recent rollup. Metrics are strictly increasing in value. To determine the value of a
given metric for an interval of time, use the MON_GET_SERVICE_SUPERCLASS table function to query the
metric at the start and end of the interval, and compute the difference.
Request metrics are controlled through the COLLECT REQUEST METRICS clause on service superclasses
and the mon_req_metrics database configuration parameter at the database level. Metrics are only
collected for a request if the request is processed by an agent in a service subclass whose parent service
superclass has request metrics enabled, or if request metrics collection is enabled for the entire
database. By default, request metrics are enabled at the database level. If request metrics are disabled at
the database level and for a service superclass, the metrics reported for each connection mapped to that
Example
Display the total CPU time used and total number of requests processed for each service superclass,
ordered by CPU usage.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_SERVICE_SUPERCLASS_DETAILS ( service_superclass_name ,
member )
Information returned
The following example shows the structure of the XML document that is returned in the DETAILS column.
Usage notes
The metrics returned by the MON_GET_SERVICE_SUPERCLASS_DETAILS table function represent the
accumulation of all metrics for requests that have executed under the indicated service superclass. This
function is similar to the MON_GET_SERVICE_SUPERCLASS table function:
• The MON_GET_SERVICE_SUPERCLASS table function returns the most commonly used metrics in a
column based format and is the most performance efficient method of retrieving metrics.
• The MON_GET_SERVICE_SUPERCLASS_DETAILS table function returns the entire set of available
metrics in an XML document format, which provides maximum flexibility for formatting output. The
XML-based output can be parsed directly by an XML parser, or it can be converted to relational format
by the XMLTABLE function (see the example).
Metrics are rolled up to a service class on unit of work boundaries, and periodically during the execution
of requests. Therefore, the values reported by this table function reflect the current state of the system at
the time of the most recent rollup. Metrics are strictly increasing in value. To determine the value of a
given metric for an interval of time, use the MON_GET_SERVICE_SUPERCLASS_DETAILS table function to
query the metric at the start and end of the interval, and compute the difference.
Request metrics are controlled through the COLLECT REQUEST METRICS clause on service superclasses,
and the mon_req_metrics database configuration parameter at the database level. Metrics are only
collected for a request if the request is processed by an agent in a service subclass whose parent service
superclass has request metrics enabled, or if request metrics collection is enabled for the entire
database. By default request metrics are enabled at the database level. If request metrics are disabled at
the database level and for a service superclass, the metrics reported for each connection mapped to that
service superclass stop increasing (or remain at 0 if request metrics were disabled at database activation
time).
The MON_GET_SERVICE_SUPERCLASS_DETAILS table function returns one row of data per service
superclass and per member. No aggregation across service classes (on a member), or across members
Example
Display the total CPU time used and total number of requests processed for each service superclass,
ordered by CPU usage in relational format (using XMLTABLE).
3 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Syntax
MON_GET_SERVICE_SUPERCLASS_STATS ( service_superclass_name , member
Information returned
Usage notes
The MON_GET_SERVICE_SUPERCLASS_STATS table function returns one row of data per service
superclass and per member. The function does not aggregate data across service superclasses (on a
member) or across members (for one or more service superclasses). However, you can use SQL queries
to aggregate data, as shown in the previous example.
Examples
Example 1: The following query displays some basic statistics for all the service superclasses on the
system, across all database members:
Example 2: Because every activity must be mapped to a database service class before being run, you can
monitor the global state of the system by using the service class statistics table functions and querying all
of the service classes on all members. In the following example, a null value is passed for
service_superclass_name to return statistics for all service superclasses, and the value -2 is specified for
member to return statistics for all members:
The statement returns service superclass statistics such as average activity lifetime and standard
deviation in seconds, as shown in the following sample output:
Example 3: The same table function can also give the highest value for average concurrency of
coordinator activities running in the service superclass on each member:
By checking the average execution times and numbers of activities in the output of this table function, you
can get a good high-level view of the load on each member for a specific database. Any significant
variations in the high-level gauges returned by this table function might indicate a change in the load on
the system.
Syntax
MON_GET_TABLE ( tabschema , tabname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Usage notes
The MON_GET_TABLE table function returns one row of data per database table and per database
member. If range-partitioned tables are being used, one row is returned for each table partition per
database member. No aggregation across database members is performed. However, aggregation can be
achieved through SQL queries as shown in the example.
Metrics are returned only for tables accessed since the database was activated.
The metrics returned by this function are collected at two levels. Some metrics are always collected,
while the collection of other metrics is controlled at the database level by using the mon_obj_metrics
configuration parameter. Refer to the descriptions provided in the following table to determine if any
settings must be active for data to be collected for a particular metric.
Examples
1. List the activity on all tables accessed since the database was activated, aggregated across all
database members, ordered by highest number of reads.
19 record(s) selected.
2. Get the explicit hierarchical locking state for tables in the schema JOE from member 1:
This output shows that table T1 is currently in a "NOT_SHARED" state and has never been forced out
of this state during the current database activation. Table T3 has never entered a "NOT_SHARED"
state. Table T2 has been in a "NOT_SHARED" state twice and has had to exit both times.
Syntax
MON_GET_TABLESPACE ( tbsp_name , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
Example
List table spaces ordered by number of physical reads from table space containers.
3 record(s) selected.
Usage notes
The MON_GET_TABLESPACE table function returns one row of data per database table space and per
database member. No aggregation across database members is performed. However, aggregation can be
achieved through SQL queries.
Metrics collected by this function are controlled at the database level by using the mon_obj_metrics
configuration parameter. By default, metrics collection is enabled.
Information returned
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
Syntax
MON_GET_TABLESPACE_QUIESCER ( member )
Routine parameters
member
An optional input argument of type SMALLINT that specifies a valid member in the same instance as
the currently connected database when you call this function. Specify -1 for the current database
member or -2 for all active database members. If the null value is specified, -1 is set.
Information returned
Usage notes
Use the MON_GET_TABLESPACE_QUIESCER table function in place of the SNAP_GET_TBSP_QUIESCER
table function and SNAPTBSP_QUIESCER view, which have been deprecated.
Examples
• Retrieve information about the quiesced table spaces for all database members for the currently
connected database.
2 record(s) selected.
• Retrieve information about the quiesced table spaces for database member 1 for the currently
connected database.
1 record(s) selected.
Use the given TBSPACEID and TABLEID provided in the output from the previous query to find the table
schema and name from SYSCAT.TABLES:
– For the table spaces TABDATA and DATAMART, run the following query:
TABSCHEMA TABNAME
------------ --------
SAMP ORDERS_RP
SAMP ORDERS_DMART
2 record(s) selected.
TABSCHEMA TABNAME
------------ --------
SAMP NATION
1 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
• DBADM authority
Syntax
MON_GET_TABLESPACE_RANGE ( dbpartitionnum )
Routine parameters
dbpartitionnum
An optional input argument of type INTEGER that specifies a valid database partition number. Specify
-1 for the current database partition, or -2 for an aggregate of all active database partitions. An active
Information returned
Usage notes
Use the MON_GET_TABLESPACE_RANGE table function in place of the SNAP_GET_TBSP_RANGE table
function and SNAPTBSP_RANGE view, which have been deprecated.
Examples
• Select information about table space ranges for all database partitions for the currently connected
database.
5 record(s) selected.
• Select information about the table space range for the table space whose TBSP_ID value is 2 on the
current database partition.
1 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_TABLE_USAGE_LIST (usagelistschema , usagelistname ,member )
Routine parameters
usagelistschema
An input argument of type VARCHAR(128) that specifies a valid schema name in the currently
connected database when calling this function. If the argument is null or an empty string, usage lists
are retrieved in all schemas in the database. If the argument is specified, usage lists are only returned
for the specified schema.
usagelistname
An input argument of type VARCHAR(128) that specifies a usage list defined for a table that resides in
the currently connected database when calling this function. If usagelistname is null or an empty
string, then all usage lists defined for a table from the schemas identified by the usagelistschema that
exist are retrieved. If specified, only the usage list specified from the schemas identified by the
usagelistschema is returned.
member
An input argument of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the NULL value is specified, -1 is set implicitly.
Information returned
Usage notes
Each row returned by this function represents the total number of times (num_references) a unique
section (DML statement only, executable ID) has referenced a particular object during a particular time
interval (monitor interval ID) since being added to the list. The statistics collected for this row represents
the total aggregated value across these executions during this time interval.
Use the num_ref_with_metrics column instead of the num_references column when computing averages,
since the num_references column counts all executions of the section, regardless of whether or not the
execution of the section contributed to the metrics that are reported.
Metrics collected by this function are controlled at the database level by using the mon_obj_metrics
configuration parameter. By default, metrics collection is enabled.
Example
Retrieve the usage list USL_MON_PAYROLL from member 3
MEMBER . . . LAST_UPDATED . . .
------ . . . -------------------------- . . .
3 . . . 2011-07-06-10.20.22.727803 . . .
3 . . . 2011-07-06-10.20.58.202161 . . .
2 record(s) selected.
Syntax
MON_GET_TRANSACTION_LOG ( member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
Example
Information returned
Table 167. Information returned for MON_GET_TRANSACTION_LOG. There will be one row per member for both
Db2 pureScale and partitioned database environments.
Column Name Data Type Description
MEMBER SMALLINT member - Database member monitor element
TOTAL_LOG_AVAILABLE BIGINT total_log_available - Total Log Available monitor
element
TOTAL_LOG_USED BIGINT total_log_used - Total Log Space Used monitor element
SEC_LOG_USED_TOP BIGINT sec_log_used_top - Maximum Secondary Log Space
Used monitor element
TOT_LOG_USED_TOP BIGINT tot_log_used_top - Maximum Total Log Space Used
monitor element
SEC_LOGS_ALLOCATED BIGINT sec_logs_allocated - Secondary Logs Allocated
Currently monitor element
LOG_READS BIGINT log_reads - Number of Log Pages Read monitor element
LOG_READ_TIME BIGINT log_read_time - Log Read Time monitor element
LOG_WRITES BIGINT log_writes - Number of Log Pages Written monitor
element
LOG_WRITE_TIME BIGINT log_write_time - Log Write Time monitor element
NUM_LOG_WRITE_IO BIGINT num_log_write_io - Number of Log Writes monitor
element
NUM_LOG_READ_IO BIGINT num_log_read_io - Number of Log Reads monitor
element
NUM_LOG_PART_PAGE_IO BIGINT num_log_part_page_io - Number of Partial Log Page
Writes monitor element
NUM_LOG_BUFFER_FULL BIGINT num_log_buffer_full - Number of times full log buffer
caused agents to wait monitor element
NUM_LOG_DATA_FOUND_IN BIGINT num_log_data_found_in_buffer - Number of Log Data
_BUFFER Found In Buffer monitor element
APPLID_HOLDING_OLDEST BIGINT Application handle holding the oldest transaction
_XACT
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_UNIT_OF_WORK ( application_handle , member
)
, system_appls
Routine parameters
application_handle
An optional input argument of type BIGINT that specifies a valid application handle in the same
database as the one currently connected to when calling this function. If the argument is null, metrics
are retrieved for units of work running in all superclasses in the database.
member
An optional input argument of type INTEGER that specifies a valid member in the same instance as
the currently connected database when calling this function. Specify -1 for the current database
member, or -2 for all active database members. If the NULL value is specified, -1 is set implicitly.
system_appls
An input parameter of data type SMALLINT that specifies whether information for system applications
is returned. The following values are valid:
• 0 or NULL: System application information is not returned. NULL is the default if a value for
system_appls is not provided.
• 1: User and system application information is returned.
Information returned
Usage notes
The metrics returned by the MON_GET_UNIT_OF_WORK table function represent the accumulation of all
metrics for requests that were submitted during a unit of work. Metrics are rolled up periodically during
the unit of work. Therefore, the values reported by this table function reflect the current state of the
system at the time of the most recent rollup. Metrics are strictly increasing in value. To determine the
value of a given metric for an in interval of time, use the function to query the metric at the start and end
of the interval, and compute the difference.
Request metrics are controlled through the COLLECT REQUEST METRICS clause on service superclasses
and the mon_req_metrics database configuration parameter at the database level. Metrics are only
collected for a request if the request is processed by an agent in a service subclass whose parent service
superclass has request metrics enabled, or if request metrics collection is enabled for the entire
database. By default, request metrics are enabled at the database level. If request metrics have been
disabled at the database level, and for a service superclass, the metrics reported for each unit of work
mapped to that service superclass stop increasing (or remain at 0 if request metrics were disabled at
database activation time).
The MON_GET_UNIT_OF_WORK table function returns one row of data per unit of work and per member.
No aggregation across units of work (on a member), or across members (for a service class or more), is
performed. However, aggregation can be achieved through SQL queries. The input parameters have the
effect of being ANDed together.
SELECT application_handle,
uow_id,
total_cpu_time,
app_rqsts_completed_total,
rqsts_completed_total
FROM TABLE(MON_GET_UNIT_OF_WORK(NULL,-1)) AS t
ORDER BY total_cpu_time DESC
1 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_UNIT_OF_WORK_DETAILS ( application_handle , member
)
, system_appls
Routine parameters
application_handle
An input argument of type BIGINT that specifies a valid application handle in the same database as
the one currently connected to when calling this function. If the argument is null, metrics are
retrieved for units of work running in all superclasses in the database.
Information returned
The following example shows the structure of the XML document that is returned in the DETAILS column.
Usage notes
The metrics returned by the MON_GET_UNIT_OF_WORK_DETAILS function represent the accumulation of
all metrics for requests that were submitted during a unit of work. This function is similar to the
MON_GET_UNIT_OF_WORK table function:
• The MON_GET_UNIT_OF_WORK table function returns the most commonly used metrics in a column
based format and is the most performance efficient method of retrieving metrics.
• The MON_GET_UNIT_OF_WORK_DETAILS table function returns the entire set of available metrics in an
XML document format, which provides maximum flexibility for formatting output. The XML based output
can be parsed directly by an XML parser, or it can be converted to relational format by the XMLTABLE
function (see the example).
Example
Identify the units of work that are consuming the highest amount of CPU time on the system.
SELECT detmetrics.application_handle,
detmetrics.uow_id,
detmetrics.total_cpu_time,
detmetrics.app_rqsts_completed_total,
detmetrics.rqsts_completed_total
FROM TABLE(MON_GET_UNIT_OF_WORK_DETAILS(NULL,-2)) AS UOWMETRICS,
XMLTABLE (
XMLNAMESPACES( DEFAULT 'http://www.ibm.com/xmlns/prod/db2/mon'),
'$detmetric/db2_unit_of_work' PASSING
XMLPARSE(DOCUMENT UOWMETRICS.DETAILS)
as "detmetric"
COLUMNS
"APPLICATION_HANDLE" INTEGER PATH 'application_handle',
"UOW_ID" INTEGER PATH 'uow_id',
"TOTAL_CPU_TIME" INTEGER PATH 'system_metrics/total_cpu_time',
"APP_RQSTS_COMPLETED_TOTAL" INTEGER
PATH 'system_metrics/app_rqsts_completed_total',
"RQSTS_COMPLETED_TOTAL" INTEGER
PATH 'system_metrics/rqsts_completed_total'
) AS DETMETRICS
ORDER BY total_cpu_time DESC
1 record(s) selected.
Syntax
MON_GET_USAGE_LIST_STATUS (usagelistschema , usagelistname ,member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Usage notes
The MON_GET_USAGE_LIST_STATUS function does not report information about usage lists that are in
the released state. A usage list is considered to be in the released state if it is defined and has not been
activated (explicitly or automatically) or has been released using the SET USAGE LIST STATE statement.
If a usage list is activated (explicitly or automatically) then the state of the usage list is set to activation
pending and the memory allocation for the usage list is deferred until the table or index for which the
usage list is defined is first referenced by a section. At which point the state of the usage list is set to
active. If the memory for the usage list cannot be allocated, then the state of the usage list is set to failed
and it must be explicitly activated using the SET USAGE LIST STATE statement.
Information returned
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_UTILITY ( member )
Routine parameters
member
An input parameter of type INTEGER that specifies a valid database member from which the records
should be fetched. Specify -1 or null for the current member, or -2 for information from all active
database members. An active database member is a database that is available for connection and use
by applications.
Example
List all LOAD commands currently running on the database server and provide information about the
applications and the users running the command.
... CMD
... ---------------------------------------------------------------------------- ...
... [LOADID: 63.2013-02-01-09.48.42.976823.0 (2;21)] [*LOCAL.user2.130201144359] ...
... [LOADID: 20.2013-02-01-09.43.49.510806.0 (2;20)] [*LOCAL.user1.130201144240] ...
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_WLM_ADMISSION_QUEUE ( )
Routine parameters
None
Usage notes
The workload manager admission queue is constantly being reordered based on current resource usage
and demand as queries are executed and admitted. As such the data returned is a point in time snapshot
of the current state of the admission queue does not necessarily reflect the future execution order. Use
this monitor interface to understand which request is currently at the head of the queue since the head
request may block additional work from entering as it is waiting for its required resources.
Note: If the adaptive workload manager is disabled, no data is returned.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
Syntax
MON_GET_WORKLOAD ( workload_name , member )
Routine parameters
workload_name
An input argument of type VARCHAR(128) that specifies a specific workload for which the metrics are
to be returned. If the argument is NULL or an empty string, metrics are returned for all workloads.
member
An input argument of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the NULL value is specified, -1 is set implicitly.
Information returned
Usage notes
The metrics returned by the MON_GET_WORKLOAD table function represent the accumulation of all
metrics for requests that were submitted by connections mapped to the identified workload object.
Metrics are rolled up to a workload on unit of work boundaries, and periodically during the execution of
requests. Therefore, the values reported by this table function reflect the current state of the system at
the time of the most recent rollup. Metrics are strictly increasing in value. To determine the value of a
given metric for an interval of time, use the MON_GET_WORKLOAD table function to query the metric at
the start and end of the interval, and compute the difference.
Request metrics are controlled through the COLLECT REQUEST METRICS clause on service superclasses
and the mon_req_metrics database configuration parameter at the database level. Metrics are only
collected for a request if the request is processed by an agent in a service subclass whose parent service
Example
Display lock information for each workload, aggregated across member, ordered by highest lock wait
time.
2 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_GET_WORKLOAD_DETAILS ( workload_name , member )
Routine parameters
workload_name
An input argument of type VARCHAR(128) that specifies a specific workload for which the metrics are
to be returned. If the argument is NULL or an empty string, metrics are returned for all workloads.
member
An input argument of type INTEGER that specifies a valid member in the same instance as the
currently connected database when calling this function. Specify -1 for the current database member,
or -2 for all active database members. If the NULL value is specified, -1 is set implicitly.
Information returned
The following example shows the structure of the XML document that is returned in the DETAILS column.
Example
Display lock information for each workload, aggregated across members, ordered by highest lock wait
time.
2 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Syntax
MON_GET_WORKLOAD_STATS ( workload_name , member )
Routine parameters
workload_name
An input argument of type VARCHAR(128) that specifies a workload for which the statistics are to be
returned. If the argument is NULL or an empty string, statistics are returned for all workloads.
member
An input argument of type INTEGER that specifies the number of a member in the same instance as
the currently connected database. Specify -1 for the current member, or -2 for all active database
members. If a null value is specified, -1 is set implicitly.
Information returned
Example
The following query displays statistics for workloads:
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Syntax
MON_GET_WORK_ACTION_SET_STATS ( work_action_set_name , member )
Routine parameters
work_action_set_name
An input argument of type VARCHAR(128) that specifies the work action set to return statistics for. If
the argument is null or an empty string, statistics are returned for all work action sets.
Information returned
Example
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 member 0, the number of activities currently running or queued are as
follows:
• ReadClass class: eight
• WriteClass class: four
• LoadClass class: two
• Unassigned: three
Sample output is as follows. Because there is no work action associated with the WriteClass work class,
the four activities to which it applies are counted in the artificial class denoted by an asterisk (*) in the
output. The three activities that were not assigned to any work class are also included in the artificial
class.
Syntax
MON_INTERVAL_INCREMENT_ID ( new_id )
Procedure parameters
new_id
An output argument of type BIGINT that returns the new monitoring interval.
Usage notes
As an autonomous procedure, MON_INCREMENT_INTERVAL_ID executes in its own transaction scope.
When the value of MON_INTERVAL_ID reaches the maximum BIGINT value, it is cycled back to 1.
Example
To increment the interval ID and return the new value in the argument. This example assumes that MY_ID
is a previously created session global variable.
CALL SYSPROC.MON_INCREMENT_INTERVAL_ID(MY_ID)
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
member )
Information returned
Usage notes
The MON_SAMPLE_SERVICE_CLASS_METRICS table function returns one row of data for each service
class in each active database, per member.
The MON_SAMPLE_SERVICE_CLASS_METRICS table function also returns an additional row of output for
each active database, per member. These additional rows show the CPU entitlement and usage for each
database as a whole. In the database rows, all fields are populated, except for the service class identifier
columns, whose values are NULL:
Example 1
Show the activity throughput and CPU velocity for a 30 second period for each service subclass across all
partitions.
3 record(s) selected.
Example 2
Show the configured shares, the estimated CPU entitlement, and the actual CPU utilization for a 5 minute
period, for each service class across all databases and partitions on the system.
12 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MON_SAMPLE_SERVICE_CLASS_METRICS ( hostname , db_name ,
Information returned
Example
Display the unit of work (UOW) throughput, activity throughput, and average CPU utilization for a 30
second period, for each workload and across all partitions.
2 record(s) selected.
MQPUBLISH
The MQPUBLISH function publishes data to MQSeries. For more details, visit the IBM MQ product page.
The MQPUBLISH function publishes the data contained in msg-data to the MQSeries publisher specified
in publisher-service, and using the quality of service policy defined by service-policy. An optional topic for
the message can be specified, and an optional user-defined message correlation identifier can also be
specified.
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.
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase
commit transactional MQ functions.
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".
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
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.
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".
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.
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 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.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
)
num-rows
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase
commit transactional MQ functions.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
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.
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.
Information returned
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.
)
num-rows
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
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.
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.
Information returned
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.
The data type of the result is CLOB(1M). If no messages are available to be returned, the result is the null
value.
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 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.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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')
Syntax
MQRECEIVE (
)
receive-service
, service-policy
, correl-id
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase
commit transactional MQ functions.
Function parameters
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, 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 message. The correl-id
is often specified in request and reply scenarios to associate requests with replies. If not specified, no
correlation id will be specified. The maximum size of correl-id is 24 bytes.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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
MQRECEIVEALL (
receive-service
, service-policy
, correl-id
)
num-rows
,
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase
commit transactional MQ functions.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
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.
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.
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.
MQRECEIVEALLCLOB
The MQRECEIVEALLCLOB 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
MQRECEIVEALLCLOB (
receive-service
, service-policy
, correl-id
)
num-rows
,
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
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.
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.
Information returned
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.
The data type of the result is CLOB(1M). If no messages are available to be returned, the result is the null
value.
)
receive-service
, service-policy
, correl-id
Function parameters
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 message. The correl-id
is often specified in request and reply scenarios to associate requests with replies. If not specified, no
correlation id will be used. The maximum size of correl-id is 24 bytes.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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".
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.
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase
commit transactional MQ functions.
Function parameters
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.
send-service
A string containing the logical MQSeries destination where the message is to be sent. If specified, the
send-service refers to a service point defined in the DB2MQ.MQSERVICE table. A service point is a
logical end-point from which a message may be sent or received. Service point definitions include the
name of the MQSeries Queue Manager and Queue. If send-service is not specified, the value of
DB2.DEFAULT.SERVICE is used. The maximum size of send-service is 48 bytes.
service-policy
A string containing the MQSeries Service Policy used in handling of this message. If specified, the
service-policy must refer to a service 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, a default
value of DB2.DEFAULT.POLICY will be used. The maximum size of service-policy is 48 bytes.
correl-id
An optional string containing a correlation identifier associated with this message. The correl-id is
often specified in request and reply scenarios to associate requests with replies. If not specified, no
correlation ID will be sent. The maximum size of correl-id is 24 bytes.
Authorization
One of the following authorities is required to execute the function:
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.
Example 2: This example sends the string "Testing 345" to the service "MYSERVICE", using the policy
"MYPOLICY", with no correlation identifier.
Example 3: This example sends the string "Testing 678" to the service "MYSERVICE", using the policy
"MYPOLICY", with correlation identifier "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.
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 through a subsequent call to MQREAD, MQRECEIVE, MQREADALL, or MQRECEIVEALL. For more
details, visit the IBM MQ product page.
The data type of the result is VARCHAR(1). The result of the function is '1' if successful or '0' if
unsuccessful.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
MQSUBSCRIBE ( topic
subscriber-service ,
service-policy ,
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase
commit transactional MQ functions.
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
Example 1: This example registers an interest in messages containing the topic "Weather". The default
subscriber-service (DB2.DEFAULT.SUBSCRIBER) is registered as the subscriber and the default service-
policy (DB2.DEFAULT.POLICY) specifies the quality of service.
VALUES MQSUBSCRIBE('Weather')
Example 2: This example demonstrates a subscriber registering interest in messages containing "Stocks".
The subscriber registers as "PORTFOLIO-UPDATES" with policy "BASIC-POLICY".
VALUES MQSUBSCRIBE('PORTFOLIO-UPDATES','BASIC-POLICY','Stocks')
MQUNSUBSCRIBE
The MQUNSUBSCRIBE function is used to unregister an existing message subscription. The subscriber-
service, service-policy, and topic are used to identify the subscription that is to be cancelled. Successful
execution of this function causes the publish and subscribe server to remove the specified subscription.
Messages with the specified topic will no longer be sent to the logical destination defined by subscriber-
service. For more details, visit the IBM MQ product page.
Syntax
MQUNSUBSCRIBE (
subscriber-service ,
service-policy ,
topic )
The schema is DB2MQ for non-transactional message queuing functions, and DB2MQ1C for one-phase
commit transactional MQ functions.
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".
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: This example cancels an interest in messages containing the topic "Weather". The default
subscriber-service (DB2.DEFAULT.SUBSCRIBER) is registered as the unsubscriber and the default
service-policy (DB2.DEFAULT.POLICY) specifies the quality of service.
VALUES MQUNSUBSCRIBE('Weather')
Authorization
The following authorization is required:
• EXECUTE privilege on the routine. EXECUTE privilege on this routine can be granted only by the security
administrator (SECADM).
Syntax
ADMIN_ROTATE_MASTER_KEY ( label )
Procedure parameters
label
An input and output parameter of type VARCHAR(255) that specifies the label of the new master key
to be rotated. The label is associated with a master key at the keystore. If a label is specified, it must
be associated with a master key at the keystore. If there is no association, the procedure fails. If this
parameter is NULL, a new master key and master key label is generated.
Note:
When the allow_key_insert_without_keystore_backup configuration knob is off you cannot
use the automatically generated master key.
Information returned
Usage notes
Rotation of the master key label should be done according to the organization's security policy. This is
similar to changing user passwords at a regular interval, which is also enforced by a security policy.
Before performing a master key rotation, you must ensure that the specified label is defined at the
keystore and mapped to an existing master key.
This procedure does not re-encrypt any of the data stored on disk.
In a partitioned database environment, ensure that all database partitions are active before calling this
procedure.
CALL SYSPROC.ADMIN_ROTATE_MASTER_KEY('UserGivenLabel')
Return Status = 0
Return Status = 0
Syntax
AUTH_GET_INSTANCE_AUTHID ( )
Authorization
EXECUTE privilege on the AUTH_GET_INSTANCE_AUTHID scalar function.
Information returned
This function returns a value of type VARCHAR(128) that specifies the authorization ID of the instance
owner.
Usage notes
A user who holds SYSADM authority does not have implicit DBADM authority. As a result, applications that
run under the instance owner account and that perform operations that are not within the scope of
SYSADM authority might experience authorization errors such as SQL1092N, SQL0551N, or SQL0552N.
The UPGRADE DATABASE and RESTORE DATABASE commands no longer grant DBADM authority to the
SYSADM group.
To obtain a list of the authorities held by the instance owner authorization ID:
1. Use the SYSPROC.AUTH_GET_INSTANCE_AUTHID() scalar function to determine the instance owner
authorization ID. For example:
1 record(s) selected.
2. Get a list of the authorities for this authorization ID. For example:
SELECT * FROM
TABLE (SYSPROC.AUTH_LIST_AUTHORITIES_FOR_AUTHID ('BOB', 'U') ) AS T
ORDER BY AUTHORITY
Example
The following example shows how to use the command line processor (CLP) to obtain the authorization ID
of the instance owner:
1
-------------------------...-------------
ZURBIE
1 record(s) selected.
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
One of the following authorities is required to execute the routine:
Information returned
D_GROUP CHAR(1) Authority granted directly to the authid when the authidtype is a
group (G), or to the group to which the authid belongs when the
authidtype is a user (U). If the authidtype is a role (R), then the
value is not applicable ('*').
• N = Not held
• Y= Held
• * = Not applicable
D_PUBLIC CHAR(1) Authority granted directly to the authid called PUBLIC when the
authidtype is a user (U) or a group (G). If the authidtype is a role
(R), then the value is not applicable ('*').
• N = Not held
• Y= Held
• * = Not applicable
ROLE_USER CHAR(1) Authority granted directly to a role granted 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 ('*'). The role could be
part of a role hierarchy.
• N = Not held
• Y= Held
• * = Not applicable
ROLE_PUBLIC CHAR(1) Authority granted directly to a role granted to the authid called
PUBLIC when the authidtype is a user (U) or a group (G). If the
authidtype is a role (R), then the value is not applicable ('*'). The
role could be part of a role hierarchy.
• N = Not held
• Y= Held
• * = Not applicable
D_ROLE CHAR(1) Authority granted to a role or to a role granted to the role. If the
authidtype is a user (U) or a group (G), then the value is not
applicable ('*'). The role could be part of a role hierarchy.
• N = Not held
• Y= Held
• * = 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 authorities. Role R1 was
granted to ALICE. LOAD authority was granted to role R1. Role R2 was granted to group ADMIN1.
CREATE_NOT_FENCED_ROUTINE authority was granted to role R2.
Example 1: Retrieve all authorities user ALICE has granted either directly to her or indirectly through a
group, PUBLIC or a role.
Example 2: Retrieve all authorities group ADMIN1 has granted either directly to it or indirectly through
PUBLIC or a role.
Example 3: Retrieve all authorities special group PUBLIC has granted either directly to it or indirectly
through a role
Example 4: Retrieve all authorities role R1 has granted either directly to it or indirectly through a role.
Consider in this case that role R2 was also granted to role R1.
Usage notes
The output of AUTH_LIST_AUTHORITIES_FOR_AUTHID table function depends on the authidtype. For
example, for an authidtype of USER, it returns all authorities that authid holds through any means:
• granted directly to the authid
• granted to any group (or roles granted to the group) to which authid belongs
• granted to any role (or roles granted to the role) granted to authid
• granted to PUBLIC (or roles granted to PUBLIC)
Syntax
AUTH_LIST_GROUPS_FOR_AUTHID ( authid )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
GROUP
-------------------------...-------------
BUILD
PDXDB2
2 record(s) selected.
Usage notes
Group information returned might be different than expected for the following reasons:
• 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.
• The registry variable DB2_GRP_LOOKUP specifies which Windows security mechanism is used to
enumerate the groups to which a user belongs.
• 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.
• If the call to AUTH_LIST_GROUPS_FOR_AUTHID is for the same authid as the connected user, then it
will return the groups for the connected user. For example, If AMY exists as a local user and as a
domain user and the domain user AMY has connected to the database, then
AUTH_LIST_GROUPS_FOR_AUTHID will return the groups to which the domain AMY belongs to.
Information returned
Syntax
AUTH_LIST_ROLES_FOR_AUTHID ( authid , authidtype )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
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
The output of AUTH_LIST_ROLES_FOR_AUTHID table function depends on the AUTHIDTYPE:
• For a user it returns the roles granted to the user directly or indirectly through another roles, groups that
the user belongs to (or PUBLIC).
• For a group it returns the roles granted to the group, directly or indirectly through another roles.
• For a role it returns the roles granted to the role, directly or indirectly through another roles.
Authorization
One of the following authorizations is required:
• SELECT privilege on the AUTHORIZATIONIDS administrative view
• CONTROL privilege on the AUTHORIZATIONIDS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Retrieve all authorization IDs that have been granted privileges or authorities, along with their types.
AUTHID AUTHIDTYPE
-------------------------...------- ----------
PUBLIC G
JESSICAE U
DOCTOR R
3 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the OBJECTOWNERS administrative view
• CONTROL privilege on the OBJECTOWNERS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Retrieve all object ownership information for object schema 'THERESAX'.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the PRIVILEGES administrative view
• SELECTIN privilege on the schema of the view
• CONTROL privilege on the PRIVILEGES administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Retrieve the privilege granted along with the object name, schema and type, for all authorization IDs.
Example 2
Attention: The following example applies to the container-only release of Db2 Version 11.5 Mod
Pack 1 or later versions as well as on premise Version 11.5 Mod Pack 4 or later versions.
Retrieve the privilege granted along with the object name, schema and type, for all authorization IDs.
Information returned
Updating SYSIBMADM.PRIVILEGES
Attention: This feature applies to the container-only release of Db2 Version 11.5 Mod Pack 1 or
later versions.
Use Db2 service tool db2updv115 to update to the latest fix pack with this command:
db2updv115 -d testdb
Authorization
One of the following authorizations is required:
• SELECT privilege on the QUERY_PREP_COST administrative view
• CONTROL privilege on the QUERY_PREP_COST administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Retrieve a report on the queries with the highest percentage of time spent on preparing.
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.
Information returned
Example
Retrieve a list of dynamic SQL run on the currently connected database, ordered by the number of rows
read.
9 record(s) selected.
... DBPARTITIONNUM
... --------------
... 0
... 0
... 0
... 2
... 1
... 2
... 2
... 1
... 0
Syntax
SNAP_GET_DYN_SQL ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DYN_SQL table function
Example
Retrieve a list of dynamic SQL run on the currently connected database, ordered by the number of rows
read.
23 record(s) selected.
... STMT_TEXT
... -----------------------------------------------------------
... SET :HV00017 :HI00017 = RPAD(VARCHAR(:HV00035 :HI00035 ),
... SELECT COLNAME, TYPENAME FROM SYSCAT.COLUMNS WHERE TABNAME=
... DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT F
... SELECT PREP_TIME_WORST, NUM_COMPILATIONS, SUBSTR(STMT_TEXT,
... VALUES (:HV00026 :HI00026 + 1, :HV00024 :HI00024 + 1) IN
... VALUES (:HV00035 :HI00035 + 1, :HV00024 :HI00024 + 1) IN
... VALUES (1) INTO :HV00035 :HI00035
... SELECT TRIGNAME FROM SYSCAT.TRIGGERS WHERE TABNAME='POLICY'
... VALUES (:HV00024 :HI00024 +1, :HV00022 :HI00022 +1) INTO :
... VALUES (1, CARDINALITY(CAST(:HV00040 :HI00040 AS "SYSIBMAD
... CALL SYSPROC.SYSINSTALLOBJECTS('POLICY','V','','')
... SET :HV00017 :HI00017 = RPAD(VARCHAR(:HV00035 :HI00035 ),
... drop event monitor act
... SELECT TABSCHEMA, TABNAME, TYPE, STATUS, TBSPACEID, PROPERTY
... CALL SAVE_EXEC_INFO (CAST(:HV00040 :HI00040 AS "SYSIBMADM"
23 record(s) selected.
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('mytestdb', -1))
AS SNAPDB
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
2 12
1 30
SELECT STATS_FABRICATE_TIME,SYNC_RUNSTATS_TIME
FROM SYSIBMADM.SNAPDYN_SQL
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
5 10
3 20
2 record(s) selected.
Information returned
Table 193. Information returned by the SNAPDYN_SQL administrative view and the SNAP_GET_DYN_SQL table
function
Column name Data type Description or corresponding 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
INT_ROWS_INSERTED BIGINT int_rows_inserted - Internal rows inserted
INT_ROWS_UPDATED BIGINT int_rows_updated - Internal rows updated
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
STMT_SORTS BIGINT stmt_sorts - Statement sorts
SORT_OVERFLOWS BIGINT sort_overflows - Sort overflows
TOTAL_SORT_TIME BIGINT total_sort_time - Total sort time
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPSUBSECTION administrative view
• CONTROL privilege on the SNAPSUBSECTION administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Get status for subsections executing on all database members.
Syntax
SNAP_GET_SUBSECTION ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_SUBSECTION table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Get status for subsections executing on all database members.
Information returned
Table 194. Information returned by the SNAPSUBSECTION administrative view and the
SNAP_GET_SUBSECTION table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPSWITCHES administrative view
• CONTROL privilege on the SNAPSWITCHES administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_SWITCHES table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Retrieve DBM monitor switches state information for all database members.
Syntax
SNAP_GET_SWITCHES ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_SWITCHES table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Retrieve DBM monitor switches state information for the current database member.
Information returned
Table 195. 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.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPTAB_REORG administrative view
• CONTROL privilege on the SNAPTAB_REORG administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_TAB_REORG table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Select details on reorganization operations for all database members on the currently connected
database.
Select all information about a reorganization operation to reclaim extents from a multidimensional
clustering (MDC) or insert time clustering (ITC) table from the SNAPTAB_REORG administrative view.
Syntax
SNAP_GET_TAB_REORG ( dbname )
, member
Example
Select details on reorganization operations for database member 1 on the currently connected database.
Select all information about a reorganization operation to reclaim extents from a multidimensional
clustering (MDC) or insert time clustering (ITC) table using the SNAP_GET_TAB_REORG table function.
Information returned
Table 196. Information returned by the SNAPTAB_REORG administrative view and the
SNAP_GET_TAB_REORG table function
Column name Data type Description or corresponding monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was taken.
RECLAIM+OFFLINE+ALLOW_READ+DATAONLY
+KEEPDICTIONARY
RECLUSTER+OFFLINE+ALLOW_READ+INDEXSCAN
+DATAONLY+KEEPDICTIONARY
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPUTIL_PROGRESS administrative view
• CONTROL privilege on the SNAPUTIL_PROGRESS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve details on total and completed units of progress by utility ID.
1 record(s) selected.
Syntax
SNAP_GET_UTIL_PROGRESS ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
1 record(s) selected.
Information returned
Table 197. Information returned by the SNAPUTIL_PROGRESS administrative view and the
SNAP_GET_UTIL_PROGRESS table function
Column name Data type Description or corresponding 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.
UTILITY_STATE VARCHAR(16) utility_state - Utility state. This interface
returns a text identifier based on the
defines in sqlmon.h
PROGRESS_DESCRIPTION VARCHAR(2048) progress_description - Progress
description
PROGRESS_START_TIME TIMESTAMP progress_start_time - Progress start
time. Start time if the phase has started,
otherwise NULL.
PROGRESS_WORK_METRIC VARCHAR(16) progress_work_metric - Progress work
metric. This interface returns a text
identifier based on the defines in
sqlmon.h and is one of:
• NOT_SUPPORT
• BYTES
• EXTENTS
• INDEXES
• PAGES
• ROWS
• TABLES
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPDYN_SQL administrative view
• CONTROL privilege on the SNAPDYN_SQL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following authorizations is required to use the table function:
• EXECUTE privilege on the SNAP_GET_DYN_SQL table function
• DATAACCESS authority
Example
Retrieve a list of dynamic SQL run on the currently connected database, ordered by the number of rows
read.
9 record(s) selected.
... DBPARTITIONNUM
... --------------
... 0
... 0
... 0
... 2
... 1
... 2
... 2
... 1
... 0
Syntax
SNAP_GET_DYN_SQL ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DYN_SQL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
23 record(s) selected.
... STMT_TEXT
... -----------------------------------------------------------
... SET :HV00017 :HI00017 = RPAD(VARCHAR(:HV00035 :HI00035 ),
... SELECT COLNAME, TYPENAME FROM SYSCAT.COLUMNS WHERE TABNAME=
... DECLARE RES CURSOR WITH RETURN TO CALLER FOR SELECT R.TEXT F
... SELECT PREP_TIME_WORST, NUM_COMPILATIONS, SUBSTR(STMT_TEXT,
... VALUES (:HV00026 :HI00026 + 1, :HV00024 :HI00024 + 1) IN
... VALUES (:HV00035 :HI00035 + 1, :HV00024 :HI00024 + 1) IN
... VALUES (1) INTO :HV00035 :HI00035
... SELECT TRIGNAME FROM SYSCAT.TRIGGERS WHERE TABNAME='POLICY'
... VALUES (:HV00024 :HI00024 +1, :HV00022 :HI00022 +1) INTO :
... VALUES (1, CARDINALITY(CAST(:HV00040 :HI00040 AS "SYSIBMAD
... CALL SYSPROC.SYSINSTALLOBJECTS('POLICY','V','','')
... SET :HV00017 :HI00017 = RPAD(VARCHAR(:HV00035 :HI00035 ),
... drop event monitor act
... SELECT TABSCHEMA, TABNAME, TYPE, STATUS, TBSPACEID, PROPERTY
... CALL SAVE_EXEC_INFO (CAST(:HV00040 :HI00040 AS "SYSIBMADM"
... SET CURRENT LOCK TIMEOUT 5
... SELECT TABNAME FROM SYSCAT.PERIODS WHERE PERIODNAME = 'SYSTE
... SELECT ARRAY_AGG(P.EXECUTABLE_ID ORDER BY M.IO_WAIT_TIME DES
... SET CURRENT ISOLATION RESET
... CALL monreport.pkgcache()
... SELECT A.SPECIFICNAME FROM SYSCAT.ROUTINES A WHERE (A.FENCED
... SELECT POLICY FROM SYSTOOLS.POLICY WHERE MED='DB2CommonMED'
... VALUES 0
23 record(s) selected.
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('mytestdb', -1))
AS SNAPDB
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
SELECT STATS_FABRICATE_TIME,SYNC_RUNSTATS_TIME
FROM SYSIBMADM.SNAPDYN_SQL
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
5 10
3 20
2 record(s) selected.
Information returned
Table 198. Information returned by the SNAPDYN_SQL administrative view and the SNAP_GET_DYN_SQL table
function
Column name Data type Description or corresponding 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
INT_ROWS_INSERTED BIGINT int_rows_inserted - Internal rows inserted
INT_ROWS_UPDATED BIGINT int_rows_updated - Internal rows updated
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
STMT_SORTS BIGINT stmt_sorts - Statement sorts
SORT_OVERFLOWS BIGINT sort_overflows - Sort overflows
TOTAL_SORT_TIME BIGINT total_sort_time - Total sort time
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_TEMP_DATA_L_READS BIGINT pool_temp_data_l_reads - Buffer pool
temporary data logical reads
POOL_TEMP_DATA_P_READS BIGINT pool_temp_data_p_reads - Buffer pool
temporary data physical reads
POOL_INDEX_L_READS BIGINT pool_index_l_reads - Buffer pool index
logical reads
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPSUBSECTION administrative view
• CONTROL privilege on the SNAPSUBSECTION administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_SUBSECTION table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
Example
Get status for subsections executing on all database members.
Syntax
SNAP_GET_SUBSECTION ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_SUBSECTION table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Get status for subsections executing on all database members.
Information returned
Table 199. Information returned by the SNAPSUBSECTION administrative view and the
SNAP_GET_SUBSECTION table function
Column name Data type Description or corresponding 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 - Currentnumber of
table queue buffers overflowed
TQ_MAX_SEND_SPILLS BIGINT tq_max_send_spills - Maximum number
of table queue buffers overflows
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPSWITCHES administrative view
• CONTROL privilege on the SNAPSWITCHES administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_SWITCHES table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve DBM monitor switches state information for all database members.
Syntax
SNAP_GET_SWITCHES ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_SWITCHES table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Retrieve DBM monitor switches state information for the current database member.
Information returned
Table 200. 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.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPTAB_REORG administrative view
Example
Select details on reorganization operations for all database members on the currently connected
database.
Select all information about a reorganization operation to reclaim extents from a multidimensional
clustering (MDC) or insert time clustering (ITC) table from the SNAPTAB_REORG administrative view.
Syntax
SNAP_GET_TAB_REORG ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TAB_REORG table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Select all information about a reorganization operation to reclaim extents from a multidimensional
clustering (MDC) or insert time clustering (ITC) table using the SNAP_GET_TAB_REORG table function.
Information returned
Table 201. Information returned by the SNAPTAB_REORG administrative view and the
SNAP_GET_TAB_REORG table function
Column name Data type Description or corresponding monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was taken.
TABNAME VARCHAR (128) table_name - Table name
TABSCHEMA VARCHAR (128) table_schema - Table schema name
PAGE_REORGS BIGINT page_reorgs - Page reorganizations
RECLAIM+OFFLINE+ALLOW_READ+DATAONLY
+KEEPDICTIONARY
RECLUSTER+OFFLINE+ALLOW_READ+INDEXSCAN
+DATAONLY+KEEPDICTIONARY
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPUTIL_PROGRESS administrative view
• CONTROL privilege on the SNAPUTIL_PROGRESS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve details on total and completed units of progress by utility ID.
1 record(s) selected.
Syntax
SNAP_GET_UTIL_PROGRESS ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_UTIL_PROGRESS table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
1 record(s) selected.
Information returned
Table 202. Information returned by the SNAPUTIL_PROGRESS administrative view and the
SNAP_GET_UTIL_PROGRESS table function
Column name Data type Description or corresponding 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.
UTILITY_STATE VARCHAR(16) utility_state - Utility state. This interface
returns a text identifier based on the
defines in sqlmon.h
PROGRESS_DESCRIPTION VARCHAR(2048) progress_description - Progress
description
PROGRESS_START_TIME TIMESTAMP progress_start_time - Progress start
time. Start time if the phase has started,
otherwise NULL.
PROGRESS_WORK_METRIC VARCHAR(16) progress_work_metric - Progress work
metric. This interface returns a text
identifier based on the defines in
sqlmon.h and is one of:
• NOT_SUPPORT
• BYTES
• EXTENTS
• INDEXES
• PAGES
• ROWS
• TABLES
Authorization
One of the following authorizations is required:
• SELECT privilege on the TOP_DYNAMIC_SQL administrative view
• CONTROL privilege on the TOP_DYNAMIC_SQL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Information returned
Example
Identify the top 5 most frequently run SQL.
5 record(s) selected.
... STMT_TEXT
... ------------------------------------------------------------
... SELECT A.ID, B.EMPNO, B.FIRSTNME, B.LASTNAME, A.DEPT FROM E
... SELECT A.EMPNO, A.FIRSTNME, A.LASTNAME, B.LOCATION, B.MGRNO
... SELECT A.EMPNO, A.FIRSTNME, A.LASTNAME, B.DEPTNAME FROM EMP
... SELECT ATM.SCHEMA, ATM.NAME, ATM.CREATE_TIME, ATM.LAST_WAIT,
... SELECT * FROM JESSICAE.EMP_RESUME
ALTER_ROUTINE_PACKAGE procedure
This procedure alters values for the package associated with a compiled SQL routine or a compiled
trigger, without the need for rebinding.
It is functionally equivalent to the ALTER PACKAGE statement, except that it takes an object name
instead of a package name as an argument. The ALTER_ROUTINE_PACKAGE procedure can be invoked
from the command line or called from an application.
options )
Procedure parameters
type
An input argument of type CHAR(2) that specifies the type of routine or compiled trigger, using one of
the following values:
• 'P ' for a procedure
• 'SP' for the specific name of a procedure
• 'F' for a compiled function
• 'SF' for a specific name of a compiled function
• 'T' for a compiled trigger
schema
An optional input argument of type VARCHAR(128), which specifies the schema of the routine or
trigger. If a schema is not specified, the value will default to the value of the CURRENT SCHEMA
special register. This parameter is case sensitive.
module
An optional input argument of type VARCHAR(128), which specifies the name of the module where
the routine resides. This parameter cannot be specified for triggers. If this parameter is not specified,
then module routines are ignored. This parameter is case sensitive.
name
An input argument of type VARCHAR(128), which specifies the name of the routine or trigger. This
parameter is case sensitive.
options
An input argument of type VARCHAR(1024), which specifies a list of any options supported by the
ALTER PACKAGE statement. At least one ALTER PACKAGE clause must be supplied within the options
parameter.
Authorization
One of the following authorities is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Alter the underlying package for an existing stored procedure by the name of UPDATE_EMPLOYEE.
Alter the package for a compiled trigger called MIN_SALARY, in the DRICARD schema.
Alter the package for a compiled function, using a three part name.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
• DATAACCESS authority
• SQLADM authority
• DBADM authority
Syntax
GET_ROUTINE_NAME ( lib_id , type , schema , module ,
name , specific_name )
Routine parameters
lib_id
An input argument of type INTEGER that specifies the LIB_ID corresponding to a compiled SQL PL
routine or trigger. This is the value of the SQLERRD(4) field in the SQLCA for a runtime SQL PL error.
type
An output argument of type CHAR(1) that specifies the type of object that raised the error, using one
of the following values:
• 'P' for a procedure
• 'F' for a function
• 'T' for a trigger
Usage notes
• When the SQLCA structure contains an error raised during the execution of an SQL PL routine or trigger,
the SQLCAID field has the value 'SQLCAM' and SQLERRM(4) has a numeric value that uniquely identifies
the object that raised the error. This unique identifier corresponds to the LIB_ID column in the
SYSCAT.ROUTINES and SYSCAT.TRIGGERS catalog views. The GET_ROUTINE_NAME routine maps a
given LIB_ID value to the corresponding object name.
• If the value provided in the first argument to SYSPROC.GET_ROUTINE_NAME does not correspond to
an SQL PL routine or trigger, the procedure returns NULL in all the output parameters, indicating that
the routine or trigger could not be found.
Example
Assume the execution of an application finishes with an error described in the following SQLCA structure:
SQLCA Information
...
sqlstate: 22012
The presence of SQLCAM in the SQLCAID field indicates that the error occurred during the execution of an
SQL PL object. The values of 3 and 13152254 in the SQLERRD(3) and SQLERRD(4) fields indicate that the
error originated in the statement at line number 3 of the SQL PL object identified by the value 13152254.
To determine what the SQL PL object is, call the SYSPROC.GET_ROUTINE_NAME in the following manner:
Return Status = 0
The values of the OUT parameters from the call to SYSPROC.GET_ROUTINE_NAME indicate that the error
was raised from the stored procedure APPDEV.PROC2.
GET_ROUTINE_OPTS ( )
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
The result of the function is a varying-length character string (VARCHAR) value with a length attribute of
1024.
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
The GET_ROUTINE_SAR procedure retrieves the necessary information to install the same routine in
another database server running the same level on the same operating system.
Important: The GET_ROUTINE_SAR procedure is deprecated, use CREATE PROCEDURE to copy a
procedure to another database.
The information retrieved by GET_ROUTINE_SAR is placed into a single BLOB string representing an SQL
archive file.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
)
, hide-body-flag
Procedure parameters
sarblob
An output argument of type BLOB(3M) that contains the routine SAR file contents.
type
An input argument of type CHAR(2) that specifies the type of routine, using one of the following
values:
• 'P ' for a procedure
• 'SP' for the specific name of a procedure
routine-name-string
An input argument of type VARCHAR(257) that specifies a qualified name of the routine. If no schema
name is specified, the default is the CURRENT SCHEMA when the routine is processed. The routine-
name-string cannot include double quotation marks (").
hide-body-flag
An input argument of type INTEGER that specifies (using one of the following values) whether or not
the routine body should be hidden when the routine text is extracted from the catalogs. Valid values
are:
0
Leave the routine text intact. This is the default value.
1
Replace the routine body with an empty body when the routine text is extracted from the catalogs.
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 required 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
The PUT_ROUTINE_SAR procedure passes the necessary file to create an SQL routine at the server and
then defines the routine.
Important: The PUT_ROUTINE_SAR procedure is deprecated, use CREATE PROCEDURE to copy a
procedure to another database.
Authorization
One of the following authorizations is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
PUT_ROUTINE_SAR ( sarblob )
, new-owner , use-register-flag
Procedure parameters
sarblob
An input argument of type BLOB(3M) that contains the routine SAR file contents.
new-owner
An input argument of type VARCHAR(128) that contains an authorization-name used for authorization
checking of the routine. The new-owner must have the necessary privileges for the routine to be
defined. If new-owner is not specified, the authorization-name of the original routine definer is used.
use-register-flag
An input argument of type INTEGER that indicates whether or not the CURRENT SCHEMA and
CURRENT PATH special registers are used to define the routine. If the special registers are not used,
the settings for the default schema and SQL path are the settings used when the routine was originally
defined. Possible values for use-register-flag:
0
Do not use the special registers of the current environment
1
Use the CURRENT SCHEMA and CURRENT PATH special registers.
If the value is 1, CURRENT SCHEMA is used for unqualified object names in the routine definition
(including the name of the routine) and CURRENT PATH is used to resolve unqualified routines and
data types in the routine definition. If the use-registers-flag is not specified, the behavior is the same
as if a value of 0 was specified.
The identification information contained in sarblob is checked to confirm that the inputs are appropriate
for the environment, otherwise an error is raised (SQLSTATE 55046). The PUT_ROUTINE_SAR procedure
then uses the contents of the sarblob to define the routine at the server.
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.
If a GET ROUTINE or a PUT ROUTINE operation (or their corresponding procedure) fails to execute
successfully, it will always return an error (SQLSTATE 38000), along with diagnostic text providing
information about the cause of the failure. For example, if the procedure name provided to GET ROUTINE
does not identify an SQL procedure, diagnostic "-204, 42704" text will be returned, where "-204" is the
SQLCODE and "42704" is the SQLSTATE, that identify the cause of the problem. The SQLCODE and
SQLSTATE in this example indicate that the procedure name provided in the GET ROUTINE command is
undefined.
Authorization
One of the following authorities is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
There are two equally valid methods to invoke REBIND_ROUTINE_PACKAGE. The only difference
between the two invocations is the method of specifying the routine name. In the first instance, the
routine-name-string variable consists of identifier names separated by periods. In the second method, the
routine is identified by separate values for each of the schema, module and name values.
Method 1:
Method 2:
options )
Procedure parameters
type
An input argument of type CHAR(2) that specifies the type of routine or compiled trigger, using one of
the following values:
• 'P ' for a procedure
• 'SP' for the specific name of a procedure
• 'F' for a compiled function
• 'SF' for a specific name of a compiled function
• 'T' for a compiled trigger
Examples
Example 1: Rebind the package of routine UPDATE_EMPLOYEE using the RESOLVE, REOPT and APREUSE
options.
Method 1:
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'P','UPDATE_EMPLOYEE','RESOLVE ANY REOPT ONCE APREUSE YES')
Method 2:
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'P','','','UPDATE_EMPLOYEE','RESOLVE ANY REOPT ONCE APREUSE YES')
Method 1:
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'P','UPDATE_EMPLOYEE','')
Method 2:
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'P','','','UPDATE_EMPLOYEE','')
Method 1:
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'T','DRICARD.MIN_SALARY','REOPT ALWAYS')
Method 2:
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'T','DRICARD','','MIN_SALARY','REOPT ALWAYS')
Method 1
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'F','DRICARD.MODULE.FUNCTION','REOPT ALWAYS')
Method 2
CALL SYSPROC.REBIND_ROUTINE_PACKAGE (
'F','DRICARD','MODULE','FUNCTION','REOPT ALWAYS')
SET_ROUTINE_OPTS
The SET_ROUTINE_OPTS procedure sets the options that are to be used for the creation of SQL
procedures in the current session.
Options set with the SET_ROUTINE_OPTS procedure override the instance-wide setting specified in the
DB2_SQLROUTINE_PREPOPTS registry variable.
The schema is SYSPROC.
Authorization
One of the following authorities is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
SET_ROUTINE_OPTS ( character-expression )
Procedure parameter
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 1: Set the options setting for the current session to NULL.
Example 2: Set the options setting for the current session to EXPLAIN YES.
Example 3: Set the options setting for the current session to EXPLAIN YES and BLOCKING NO.
Syntax
ANALYZE_LOG_SPACE ( inDBPGroup , inMainTbSchema , inMainTable
pNumber , 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:
• 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.
• 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:
• 'A': Adding database partitions.
• 'D': Dropping database partitions.
• 'N': No adding or dropping.
addDropList
An input argument of type VARCHAR (6000) that specifies the database partitions to be added or
dropped. This database partition numbers are specified in a comma-separated string format and no
spaces are allowed in the string.
Authorization
• SYSADM, SYSMON, SYSCTRL, or SYSMAINT
• 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 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
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 target ratio of 1 : 1. Note that in this example, all database
partitions 10, 20 and 30 should exist in the database partition group
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 partitions of the given database partition
group.
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
• EXECUTE privilege on the GENERATE_DISTFILE procedure.
• SELECT privilege on SYSCAT.TABLES, SYSCAT.COLUMNS, and the specified table.
In addition, the fenced user ID must be able to create files in the tmp sub-directory under the instance
directory.
Example
Generate a data distribution file to be used by the redistribute process.
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 identifier(s) from Table 205 on
page 1036, 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 remainder of the output parameters can be null.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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 identifier(s) from Table 206 on page 1038 indicating the target fields to be written or
overwritten into the redistribute settings registry.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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. If the parameter is set to
a positive integer and is not NULL, the STEPWISE_REDISTRIBUTE_DBPG procedure uses this value
instead of using the nextStep value specified in the setting file. This is a useful option when you want
to rerun the STEPWISE_REDISTRIBUTE_DBPG procedure from a particular step. If the parameter is
set to NULL, the nextStep value is used.
inNumSteps
An input argument of type SMALLINT that specifies the number of steps to run. If the parameter is set
to a positive integer and is not NULL, the STEPWISE_REDISTRIBUTE_DBPG procedure uses this value
instead of using the stageSize value specified in the setting file. This is a useful option when you want
to rerun the STEPWISE_REDISTRIBUTE_DBPG procedure with a different number of steps than what
is specified in the settings. For example, if there are five steps in a scheduled stage, and the
redistribution process failed at step 3, the STEPWISE_REDISTRIBUTE_DBPG procedure can be called
to run the remaining three steps once the error condition has been corrected. If the parameter is set
to NULL, the stageSize value is used. The value -2 can be used in this procedure to indicate that the
number is unlimited.
Note: There is no parameter for specifying the equivalent of the NOT ROLLFORWARD RECOVERABLE
option on the REDISTRIBUTE DATABASE PARTITION GROUP command. Logging is always performed
for row data redistribution performed when the STEPWISE_REDISTRIBUTE_DBPG procedure is used.
Authorization
• EXECUTE privilege on the STEPWISE_REDISTRIBUTE_DBPG procedure
Example
Redistribute the database partition group "IBMDEFAULTGROUP" according to the redistribution plan
stored in the registry by the SET_SWRD_SETTINGS procedure. It is starting with step 3 and redistributes
the data until 2 steps in the redistribution plan are completed.
CALL SYSPROC.STEPWISE_REDISTRIBUTE_DBPG('IBMDEFAULTGROUP', 3, 2)
For a full usage example of the stepwise redistribute procedures, refer to "Redistributing database
partition groups using the STEPWISE_REDISTRIBUTE_DBPG procedure" in the Partitioning and Clustering
Guide.
Usage notes
If the registry value for processState is updated to 1 using the SET_SWRD_SETTINGS procedure after the
STEPWISE_REDISTRIBUTE_DBPG procedure execution is started, the process stops at the beginning to
the next step and a warning message is returned.
As the SQL COMMIT statement is called by the redistribute process, running the redistribute process
under a Type-2 connection is not supported.
Authorization
• EXECUTE privilege on the CAPTURE_STORAGEMGMT_INFO procedure.
• EXECUTE privilege on the SYSPROC.DB_PARTITIONS, SYSPROC.MON_GET_TABLESPACE,
SYSPROC.MON_GET_CONTAINER, and SYSPROC.WLM_SET_CONN_ENV routines.
• SELECT privilege on SYSCAT.TABLES, SYSCAT.TABLESPACES, SYSCAT.NODEGROUPDEF,
SYSCAT.DATABASEPARTITIONS, SYSCAT.DATAPARTITIONEXPRESSION, SYSCAT.INDEXES, and
SYSCAT.COLUMNS.
in_rootName )
Procedure parameters
in_rootType
An input argument of type SMALLINT. The valid option types are:
• 0 - Database
• 1 - Database Partition Group
• 2 - Table Space
• 4 - Table
• 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.
in_rootSchema
An input argument of type VARCHAR (128) that specifies the schema name of the storage snapshot
root object. A NULL value can be specified if the in_rootType is a database, a database partition group,
or a table space.
in_rootName
An input argument of type VARCHAR (128) that specifies the name of the root object. The input
argument cannot be null. If a null value is specified, an SQL0443 error with SQLSTATE 38553, and
token DBA7617 is returned.
Usage notes
1. The following stored procedure should be used to create storage management tables:
create_storagemgmt_tables(TABLESPACE_NAME) where 'TABLESPACE' is the name of the table
space, on which storage management tables would be created.
(In case of a problem with the existing storage management tables, it can be dropped using the
following stored procedure and can be re-created using the preceding stored procedure.
drop_storagemgmt_tables(0 or 1) where '0' indicates 'stop' and '1' indicates 'proceed' on
encountering an error.)
2. The following command should be used to run statistics for the storage object for which details have to
be obtained:
RUNSTATS ON TABLE (TABLESCHEMA.TABLENAME) ON KEY COLUMNS AND INDEXES ALL
3. The following command should be used to populate the storage management tables:
Run 'capture_storagemgmt_info()' stored procedure to populate the storage management tables.
Sometimes it might be necessary to run the CAPTURE_STORAGEMGMT_INFO procedure twice. The
first time you run it, use the CAPTURE_STORAGEMGMT_INFO procedure to populate the storage
tables with table space details. For example:
db2 "call capture_storagemgmt_info(0,<SCHEMA_NAME>,<DATABASE_NAME>)"
The second time, use the CAPTURE_STORAGEMGMT_INFO procedure to add details about the storage
of the actual object to the storage table. For example, the following example adds details for an object
of type index (the in_rootType argument is set to 5):
db2 "call
capture_storagemgmt_info(5,<SCHEMA_NAME>,<SCHEMA_NAME.INDEX_NAME>)"
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
EXECUTE privilege on the CREATE_STORAGEMGMT_TABLES procedure.
You must also have CREATETAB privilege on the database and USE privilege on the table space, and one
of:
• IMPLICIT_SCHEMA authority on the database, if the implicit or explicit schema name DB2TOOLS does
not exist.
• CREATEIN privilege on the schema, if the schema name of the table exists.
• DBADM authority
Usage notes
The following tables are created in the DB2TOOLS schema:
• STMG_CONTAINER
• STMG_CURR_THRESHOLD
• STMG_DATABASE
• STMG_DBPARTITION
• STMG_DBPGROUP
• STMG_HIST_THRESHOLD
• STMG_INDEX
• STMG_OBJECT
• STMG_OBJECT_TYPE
• STMG_ROOT_OBJECT
• STMG_TABLE
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
EXECUTE privilege on the DROP_STORAGEMGMT_TABLES procedure.
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:
• DBADM authority
• DROPIN privilege on the schema for these tables
• CONTROL privilege on these tables
Authorization
EXECUTE privilege on the SYSTS_ADMIN_CMD procedure and the required authorization as listed for the
requested operation.
Syntax
SYSTS_ADMIN_CMD ( command-string , message-locale , message )
Procedure parameters
command-string
An input argument of type VARCHAR (32 K) that specifies a single Text Search index administration
command to be executed. The command syntax is the same as the Text Search command except for
the connection options, which are not supported through this procedure. Commands that you issue
through this procedure use the current connection.
The procedure supports the following Text Search commands:
• ALTER INDEX
• CLEAR COMMAND LOCKS
• CLEAR EVENTS
• CREATE INDEX
• DISABLE DATABASE
• DROP INDEX
• ENABLE DATABASE
• RESET PENDING
• UPDATE INDEX
message-locale
An input argument of type VARCHAR(33) that specifies the language for any error message text that is
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.
CALL SYSPROC.SYSTS_ADMIN_CMD
('UPDATE INDEX DB2TS.MYTEXTINDEX FOR TEXT','en_US', ?)";
Return Status = 0
Usage notes
If the command does not run successfully, SQLCODE -20427 and SQLSTATE 38H14 are returned with the
text-search-specific error message. For example, if index MYTEXTINDEX exists and the following
statement is issued:
If an SQLCODE is returned by the procedure, the message might be truncated. Full message information
is in the db2diag log files.
Authorization
The privileges that are held by the authorization ID of the statement must include the SYSTS_MGR role
and at least one of the following authorities:
• DBADM authority
• ALTERIN privilege on base schema
• CONTROL or ALTER privilege on the base table on which the text search index is defined
To change an existing schedule, the authorization ID must be the same as the index creator, or must have
DBADM authority.
Syntax
SYSTS_ALTER ( index_schema , index_name , update characteristics
update frequency
update frequency
D ( * ) H ( * )
, ,
integer1 integer2
M ( integer3 )
options
activation options
option-value
UPDATEAUTOCOMMIT
commitcount_number
commitsize
COMMITTYPE committype
COMMITCYCLES commitcycles
activation options
SET ACTIVE
UNILATERAL
INACTIVE
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 database schema names. If the argument is null
or an empty string, the value of the current schema is used. The index_schema is case-sensitive.
activation options
Specifies an input argument of type integer that sets the status of a text index.
ACTIVE
Sets the text index status to active.
INACTIVE
Sets the text index status to inactive.
UNILATERAL
Specifies a unilateral change that affects the status of Text Search indexes. If you specify this
argument, only the status of a Text Search index is changed to active or inactive. Without the
UNILATERAL argument, the activation status of the Text Search and Net Search Extender indexes
is jointly switched so that only one of the text indexes is active.
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, the update characteristics of a text search index are being altered.
This index was originally created with index_schema 'db2ts' and index_name 'myTextIndex'. By
using 'UPDATE FREQUENCY NONE', the intention is to make no further updates to the text search index
as possibly no changes are expected for the associated table column. Any error messages are requested
to be returned in English. When the procedure is complete, a success message is returned to the caller.
Return Status = 0
Usage notes
• Text search administration procedures use an existing connection to the database. You should commit
all transaction changes before issuing a text search administration procedure to avoid any unexpected
impact from a commit or rollback. One way to achieve this is to turn on AUTOCOMMIT.
• You cannot run multiple procedures or commands 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
– SYSTS_DROP procedure or DROP INDEX db2ts command
– SYSTS_UPDATE procedure or UPDATE INDEX db2ts command
– SYSTS_CONFIGURE procedure
If there is a conflict, the procedure returns an SQLCODE -20426 and SQLSTATE 38H13.
• When you run this procedure to change the frequency, a schedule task is created, updated or dropped
for the text index.
• The result of activating indexes depends on the original index status. The following table describes the
results.
SQL20427N and CIE0379E error messages are returned for active index conflicts.
You can specify the UPDATEAUTOCOMMIT index configuration option without type and cycles for
compatibility with an earlier version. This index configuration option is associated by default with the
COMMITTYPE rows option and unrestricted cycles.
The UPDATEAUTOCOMMIT, COMMITTYPE, and COMMITSIZE index configuration options are also specified
for an UPDATE INDEX operation to override the configured values. Values that you submit for a specific
update operation are applied only once and not persisted.
Authorization
The privileges held by the authorization ID of the statement must include the SYSTS_ADM role with
DBADM and DATAACCESS authority.
Syntax
SYSTS_CLEANUP ( options , message_locale , message )
Procedure parameters
options
An input argument of type VARCHAR(32K). Only a NULL or an empty parameter is accepted. Reserved
for internal IBM use.
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.
Example
Example 1: In the following example, all invalid text search indexes in the current database are dropped.
The message language is set to English, and when the procedure succeeds, the output parameter
message indicative of the successful operation is returned to the caller.
Return Status = 0
Authorization
The privileges held by the authorization ID of the statement used to clear locks on the index must include
both of the following authorities:
• SYSTS_MGR role
• DBADM authority or CONTROL privilege on the base table on which the index is defined
The privileges held by the authorization ID of the statement used to clear locks on the database
connection must include the SYSTS_ADM role.
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 database 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. If the argument is null or an
empty string, the procedure deletes command locks for all text search indexes in the 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.
Return Status = 0
Usage notes
• Text search administration procedures use an existing connection to the database. It is recommended
to commit all transaction changes before executing a text search administration procedure to avoid any
unexpected impact from a commit or rollback in the procedure. One way to achieve this is to turn on
AUTOCOMMIT.
• You would invoke this procedure because the process owning the command lock is dead. In this case,
the command (represented by the lock) may not have completed, and the index may not be operational.
You need to take appropriate action. For example, the process executing the DROP INDEX command
dies suddenly. It has deleted some index data, but not all the catalog and collection information. The
command lock is left intact. After clearing the DROP INDEX command lock, you may want to re-execute
the SYSTS_DROP procedure. In another example, the process executing the UPDATE INDEX command
is interrupted. It has processed some documents, but not all, and the command lock is still in place.
After reviewing the text search index status and clearing the UPDATE INDEX command lock, you can re-
execute the UPDATE INDEX command.
• When this procedure is run, the content of the Text Search view SYSIBMTS.TSLOCKS is updated.
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 database 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.
Examples
Example 1: In the following example, SYSTS_CLEAR_EVENTS is being called for a text search index that
was created with index_schema 'db2ts' and index_name 'myTextIndex'. 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.
Return Status = 0
Example 2: In the following example, SYSTS_CLEAR_EVENTS is called to clear the event table entries for
a text search index with index_schema 'db2ts' and index_name 'myTextIndex2'. This index does not
exist and results in an error.
Usage notes
• 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.
• 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
– SYSTS_DISABLE procedure or DISABLE DATABASE FOR TEXT db2ts command
– SYSTS_DROP procedure or DROP INDEX db2ts command
– SYSTS_CONFIGURE procedure
– SYSTS_UPDATE procedure or UPDATE INDEX db2ts command
If there is a conflict, the procedure returns an SQLCODE -20426 and SQLSTATE 38H13.
• When regular updates are scheduled (see UPDATE FREQUENCY options in SYSTS_CREATE or
SYSTS_ALTER procedures), the event table should be checked regularly.
• To clean up the Text Search event table for a text search index, use the SYSTS_CLEAR_EVENTS
procedure or CLEAR EVENTS FOR INDEX db2ts command after you have checked the reason for the
event and removed the source of the error.
• Ensure that changes have been made to all rows referenced in the event table. By changing the rows in
the user table, you ensure that when you run the SYSTS_UPDATE procedure or UPDATE INDEX db2ts
command again, an attempt is made to index the erroneous documents again.
• When this command is issued, the event table is cleared.
• If the view already contains a row then use a SQL UPDATE statement. For example:
Authorization
The privileges held by the authorization ID of the statement must include the SYSTS_ADM role.
Syntax
SYSTS_CONFIGURE ( options , message-locale , message )
Procedure parameter
options
An input argument of type VARCHAR(32K) that specifies the options to be used. If no options are
needed, the argument can be null or an empty string.
message-locale
An input argument of type VARCHAR(33) that specifies the locale to be used for any returned error
message. If the argument is null, 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.
Example
Example 1: Prepare a database for text search services and return any messages in English.
Return Status = 0
Usage notes
• A SYSIBMTS.TSSERVERS view is created when a database is enabled for text search. This view is
updated with information about the integrated text search server during database enablement. If the
text search server configuration cannot be obtained, the enable operation will end with an 'incomplete
enablement' warning.
• The SYSTS_CONFIGURE procedure must be issued anytime a row is inserted or updated into
SYSIBMTS.TSSERVERS. Make sure that no text search administration operation is active and shut down
the text search server before updating SYSIBMTS.TSSERVERS.
• When updating SYSIBMTS.TSSERVERS in a database, all text search enabled databases should be
updated with the same parameters. Only a single text search server is supported with a given database
instance.
• Running the SYSTS_CONFIGURE procedure for a database registers the use of the configured text
search server for the instance. Not running the procedure does not result in a severe error but the
response to some commands can be unexpected.
• 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
– SYSTS_DISABLE procedure
– SYSTS_CONFIGURE procedure
– SYSTS_UPDATE procedure
If there is a conflict, the procedure returns an SQLCODE -20426 and SQLSTATE 38H13.
• Certain aspects relating to the text search installation and database instance configuration for text
search have to be updated. They include:
– An indication whether the search server utilized by the database instance is integrated (configured by
the database system as part of the database instance), or if it is a separate stand-alone installation of
the ECMTS server.
– An indication if the text search setup is enabled for rich text support.
Syntax
SYSTS_CREATE ( index_schema , index_name , text source ,
text source
table_name ( text column name ) ,
table_schema
function_name (column_name)
options
update characteristics
storage options
FORMAT format
update characteristics
update frequency
integer1 integer2
M ( integer3 )
storage options
option value
COMMENT text
UPDATEAUTOCOMMIT
commitcount_number
commitsize
COMMITTYPE committype
COMMITCYCLES commitcycles
INITIALMODE initialmode
LOGTYPE ltype
AUXLOG auxlog_value
CJKSEGMENTATION cjksegmentation_method
INITIALMODE initialmode String Specifies how the updates are processed. The possible
values of the INITIALMODE index option are as follows:
FIRST
The first update is the default value of the
INITIALMODE option.
SKIP
The update mode is immediately set to
incremental, triggers are added for the
LOGTYPEBASIC option, but no initial update is
performed.
NOW
The update is started after the index is created as
the final part of the CREATE INDEX command
operation. This option is supported only for single-
node setups.
LOGTYPE ltype String Specifies whether triggers are added to populate the
primary log table. The values are as follows:
BASIC
The primary staging table is created, and triggers
are created on the text table to recognize any
changes. This is the default value for text search
indexes on base tables. This option is not
supported for nicknames.
CUSTOM
The primary staging table is created, but no triggers
are created on the text table. Identify changes for
incremental updates, especially if you do not plan
to use the ALLROWS option for updates. The
CUSTOM option is supported for nicknames.
Note: The default value of the LOGTYPE option is
CUSTOM for text search indexes on nicknames.
AUXLOG auxlog String Controls the creation of the additional log infrastructure
_value to capture changes that are not recognized by a trigger.
The default setting for range-partitioned tables is ON.
You can change the default value in the default table by
setting AuxLogNorm for non-range-partitioned tables
and AuxLogPart for range-partitioned tables.
For text search indexes on nicknames, only the OFF
option can be enabled for the AUXLOG option to disable
support for this index configuration option.
You cannot change the auxiliary log infrastructure
property for a text index after you create it.
Important: You must enclose non-numeric values, such as comments, in single quotation marks.
A single quotation mark character within a string value must be represented by two consecutive
single quotation marks, as shown in the following example:
message_locale
An input argument of type VARCHAR(33) that specifies the locale to use for error messages. 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, the SYSTS_CREATE procedure is called to create a text search index
called myTextIndex. The UPDATE MINIMUM 10 parameter specifies that 10 changes must be made to
the text documents that are associated with the index before an incremental update of the index is
performed. Any error messages are returned in English. When the underlying text search command runs
successfully, the message output parameter is set to indicate the status of the command execution.
Example 2: In the following example, the SYSTS_CREATE procedure is called to create a text search index
called myTextIndex2. No options are specified. In this example, the index exists, which results in an error
message being returned to the caller.
Usage notes
• Text search administration procedures use an existing connection to the database. If a previous
transaction was not committed before you perform a text search administration operation, a deadlock
might occur because the same database objects might be affected and the operation waits for the
previous transaction to be committed. This situation might occur, for example, when AUTOCOMMIT
option is turned off and you create a table and then create a text index without an explicit commit
between the two transactions.
• If you do not specify the COLLECTION DIRECTORY parameter, the collection is placed in a subdirectory
that is named by using the system-generated index identifier in the path that you define by using the
defaultDataDirectory parameter in the text server configuration. You can use the configTool utility to
set this parameter. If you do not set the defaultDataDirectory parameter, the collection subdirectory is
in the configPath/config/collections directory.
You should specify a location other than the home directory or the database instance path for the
defaultDataDirectory or COLLECTION DIRECTORY parameter. Make sure that the location has
adequate storage space and is local, not NFS mounted.
• Configure a value for the COLLECTION DIRECTORY parameter that enables the use of a striped RAID
device.
The following key-related rules apply:
• You must define a primary key for the table.
• The maximum number of primary key columns is two columns fewer than the maximum number of
primary key columns in other environments.
• The maximum total length of all primary key columns for a table with Text Search indexes is 15 bytes
fewer than the maximum total primary key length that is allowed in other environments. See the
restrictions for the CREATE INDEX statement.
If you create an index with the LANGUAGE parameter set to the AUTO option, you can specify the
CJKSEGMENTATION option.
You cannot issue certain procedures or commands concurrently for a text search index because they
might result in an error, based on the timing of the conflicting operation:
• The SYSTS_DISABLE procedure or db2ts DISABLE DATABASE FOR TEXT command
• The SYSTS_CONFIGURE procedure
Successful execution of the CREATE INDEX command has the following effects:
• Text Search server data is updated. A collection with the name instance_database-
name_index_identifier_number is created, as in the following example:
tigertail_MYTSDB_TS250517_0000
For partitioned databases, a collection is created for each partition. You can retrieve the collection
names from the COLLECTIONNAME column in the SYSIBMTS.TSCOLLECTIONNAMES view.
• An index event table is created in the specified table space. Also, an index staging table is created in the
specified table space with accurate database indexes. If you specified the AUXLOG ON option for the
INDEX CONFIGURATION parameter, a second staging table is created to capture changes through
integrity processing.
• Text Search catalog information is updated. However, the new text search index is not automatically
populated. To populate the text search index, the SYSTS_UPDATE procedure or UPDATE INDEX
command must be issued either manually or automatically (as a result of defining an update schedule
for the index by using the UPDATE FREQUENCY parameter).
The AUXLOG option is supported for nicknames for data columns that support a materialized query table
(MQT) with deferred refresh. It is not supported for views.
To create a text search index on a nickname, the nickname must be a non-relational flat file nickname.
Non-relational XML nicknames are not supported.
For compatibility with an earlier version, you can specify the UPDATEAUTOCOMMIT index configuration
option without type and cycles. This option is associated by default with the COMMITTYPE rows option
and unrestricted cycles.
To override the configured values, you can specify the UPDATEAUTOCOMMIT, COMMITTYPE, and
COMMITSIZE index configuration options for the UPDATE INDEX command. Values that you submit for a
specific update operation are applied only once and are not persisted.
If you specify the INITIALMODE SKIP option, the text search index manager populates the index. Use
this option to control the sequence in which data from the text table is initially processed.
The following rules apply to the LOGTYPE index configuration option:
• If you use the LOGTYPE CUSTOM setting, use the SYSIBMTS.TSSTAGING administrative view to insert
log entries for new, changed, and deleted documents.
• To view the settings for an index, check the value of the LOGTYPE parameter in the
SYSIBMTS.TSCONFIGURATION administrative view.
• To view the default log type that is applied to new text indexes, check the value of theLOGTYPE option
in the SYSIBMTS.TSDEFAULTS administrative view.
• The LOGTYPE option is not valid with the ALLROWS option of the CREATE INDEX command because the
ALLROWS option forces an initial update and no log tables are created.
Authorization
The privileges held by the authorization ID of the statement must include the following authorities:
• DBADM with DATAACCESS authority.
• SYSTS_ADM role
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 or warning is returned. If the argument is null or an empty string, an attempt is made to
disable the Text Search feature for the database.
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, 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 to be returned in English. The
message output parameter is set to an informational message string.
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 before disabling the
Text Search feature or alternatively to specify the FORCE option for the options input parameter value.
Usage notes
• Text search administration procedures use an existing connection to the database. It is recommended
to commit all transaction changes before executing a text search administration procedure to avoid any
unexpected impact from a commit or rollback in the procedure. One way to achieve this is to turn on
AUTOCOMMIT.
• Multiple procedures or commands cannot be executed concurrently on a text search index if they might
conflict. Some of the conflicting procedures are:
Authorization
The privileges held by the authorization ID of the statement must include the SYSTS_MGR role and at
least one of the following privileges or authorities:
• CONTROL privilege on the table on which the index is defined
• DROPIN privilege on the schema on which the index is defined
• If the text search index has an existing schedule, the authorization ID must be the same as the index
creator, or must have DBADM authority
, 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 database 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.
options
An input argument of type VARCHAR(32000) that specifies the options to be used. If no options are
needed, the argument can be null or an empty string.
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, 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.
As in previous releases, the SYSTS_DROP procedure is supported without the options argument, for
example :
Return Status = 0
Example 2: In the following example, SYSTS_DROP is called to drop a text search index with
index_schema 'db2ts' and index_name 'myTextIndex2'. This index does not exist and results in an
error.
Usage notes
• Multiple procedures or commands cannot be executed concurrently on a text search index if they might
conflict. Some of the conflicting procedures are:
– SYSTS_ALTER procedure
– SYSTS_CLEAR_EVENTS procedure
– SYSTS_DISABLE procedure
– SYSTS_DROP procedure
– SYSTS_UPDATE procedure
– SYSTS_CONFIGURE procedure
A STOP FOR TEXT command that runs in parallel with the DROP operation will not cause a conflicting
command message, instead, if the text search server is shut down before DROP has removed the
collection, an error will be returned that the text search server is not available.
• After a text search index is dropped, text search is no longer possible on the corresponding text column.
If you plan to create a new text search on the same text column, you must first disconnect from the
database and then reconnect before creating the new text search index.
• The db2ts DROP INDEX command makes the following changes to the database:
– Updates the Text Search catalog information.
– Drops the index staging and event tables.
– Deletes triggers on the user text table.
– Destroys the collection associated with the Text Search index definition.
Authorization
The privileges held by the authorization ID of the procedure must include the SYSTS_ADM role and the
DBADM authority.
Syntax
SYSTS_ENABLE ( options , message_locale , message )
options
Examples
Example 1: Enable the database for text search by creating administration tables in a table space with any
output messages in English.
Enable the database for text search by creating administration tables in a table space with any output
messages in French.
As in previous releases, the SYSTS_ENABLE procedure is supported without the options argument, for
example:
Return Status = 0
Example 2: In the following example, SYSTS_ENABLE is called on a database that is already enabled for
text search. This results in an error message to the caller.
CALL SYSPROC.SYSTS_ENABLE('en_US', ?)
Usage notes
• Text search administration procedures use an existing connection to the database. It is recommended
to commit all transaction changes before executing a text search administration procedure to avoid any
unexpected impact from a commit or rollback in the procedure. One way to achieve this is to turn on
AUTOCOMMIT.
• When this procedure is run, the following events occur:
– This procedure creates database objects, such as text search administration catalog tables and
views, in the schema SYSIBMTS.
– The established database defaults for text search index are available in view
SYSIBMTS.TSDEFAULTS.
– When the command has successfully completed, the text search catalog tables and views are
created and are available.
• When executing this procedure, if you do not have sufficient execution and file access privileges to
retrieve the Text Search server configuration, the procedure will create the text search catalog with an
'Incomplete enablement' warning. In this case, the Text Search server connection information will need
to be updated manually.
Authorization
The privileges that are held by the authorization ID of the statement must include the SYSTS_MGR role
and at least one of the following authorities:
• DATAACCESS authority
• CONTROL privilege on the table on which the text index is defined
• INDEX with SELECT privilege on the base table on which the text index is defined
In addition, for an initial update the authorization requirements apply as outlined in the CREATE
TRIGGER statement.
Syntax
SYSTS_UPDATE ( index_schema , index_name , update_options ,
message_locale , message )
For incremental updates, log entries that are processed are removed
correspondingly from the staging table with each interim commit.
COMMITCYCLES Specifies the number of commit cycles. The default is 0 for unlimited
cycles.
If cycles are not explicitly specified, the update operation uses as many
cycles as required based on the batch size that is specified with the
UPDATEAUTOCOMMIT option to finish the update processing.
You can use this option with the UPDATEAUTOCOMMIT setting with a
committype.
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, 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. For successful procedures, the caller receives a success
message.
CALL SYSPROC.SYSTS_UPDATE
('db2ts', 'myTextIndex', '', 'en_US', ?)
Example 2: Update a text index after an operation finishes on the partition group that is associated with
the base table, and return any error messages in English.
CALL SYSPROC.SYSTS_UPDATE
('db2ts', 'myTextIndex2', 'FOR DATA REDISTRIBUTION', 'en_US', ?)
Return Status = 0
Example 3: In the following example, SYSTS_UPDATE is called to update a text search index with
index_schema 'db2ts' and index_name 'myTextIndex3'. In this example, the index does not exist
and results in an error.
Usage notes
• 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. To
avoid any unexpected impact from such a commit or rollback, you might want to commit all transaction
changes. Turning on AUTOCOMMIT is one way to commit all transaction changes.
• Certain procedures or commands cannot be executed concurrently on a text search index because the
timing of the conflicting operation might cause an error. Some of the conflicting procedures and
commands are:
– SYSTS_ALTER procedure or db2ts ALTER INDEX command
– SYSTS_CLEAR_EVENTS procedure or db2ts CLEAR EVENTS FOR INDEX command
– SYSTS_DISABLE procedure or db2ts DISABLE DATABASE FOR TEXT command
– SYSTS_UPDATE procedure or db2ts UPDATE INDEX command
If there is a conflict, the procedure returns an SQLCODE -20426 and SQLSTATE 38H13.
• This procedure does not return until all index update processing is completed. The duration depends on
the number of documents to be indexed and the number of documents already indexed. The collection
name for the index can be retrieved from the SYSIBMTS.TSCOLLECTIONNAMES view
COLLECTIONNAME column.
• When there are individual document errors, the documents must be corrected. The primary keys of the
erroneous documents can be looked up in the event table for the index. By changing the corresponding
rows in the user table, the next call to SYSTS_UPDATE reprocesses these documents.
• When the SYSTS_UPDATE procedure is run, the following events occur:
– Rows are inserted into the event table, including parser error information. Information is deleted
from the index staging table in case of incremental updates. Before the first update, the
SYSTS_UPDATE procedure creates triggers on the user table.
– The collection is updated:
- New or changed documents are parsed and indexed.
- Deleted documents are discarded from the index.
• If a synonym dictionary is associated with a text index, issuing the update with the ALLROWS or FOR
DATA REDISTRIBUTION options removes the association by dropping and re-creating the collections
for the text index. The synonym dictionary must be associated with the new text index collections.
• The UPDATEAUTOCOMMIT index configuration option can be specified without type and cycles for
compatibility with an earlier version. It is associated by default with the COMMITTYPE rows option and
unrestricted cycles.
• When UPDATEAUTOCOMMIT, COMMITTYPE or COMMITSIZE values are specified for the update
operation, they override existing configured values only for the specific update and are not persisted.
update.
Syntax
SYSTS_UPGRADE_CATALOG ( 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.
Example
Example 1: In the following example, the database was enabled for text search in an older release. Calling
the SYSTS_UPGRADE_CATALOG procedure upgrades the text search catalog tables, and if the procedure
succeeds, the output parameter message indicating successful operation is returned to the caller.
CALL SYSPROC.SYSTS_UPGRADE_CATALOG('en_US',?)
Return Status = 0
Example 2: In the following example, the database was not enabled for Text Search in an older release
before calling the procedure. A NULL value in the place message_locale means the a default locale of
'en_US' will be used. All error messages are returned in English.
CALL SYSPROC.SYSTS_UPGRADE_CATALOG('',?)
Example 3: In the following example, the text search catalog and the text search indexes are already
upgraded to the current version.
CALL SYSPROC.SYSTS_UPGRADE_CATALOG('en_US',?)
Usage notes
The SYSTS_UPGRADE_CATALOG procedure is integrated into the DB2 UPGRADE DATABASE command to
perform the text search specific catalog upgrade. If the database upgrade fails to upgrade the text search
catalog, the SYSTS_UPGRADE_CATALOG procedure must be executed separately by the user to complete
the database upgrade.
To upgrade the text search index catalog, proceed as follows:
1. Make sure that the Text Search instance service is stopped.
2. Execute the SYSTS_UPGRADE_CATALOG procedure.
Note: Text Search administrative 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.
3. The SYSTS_UPGRADE_CATALOG procedure attempts to populate the Text Search server information in
the catalog. Review the SYSIBMTS.TSSERVER content and update the Text Search server information
as necessary.
4. Upgrade the text search indexes by following the procedure outlined for the SYSTS_UPGRADE_INDEX
procedure. The version value in the SYSIBMTS.TSDEFAULTS administrative view will not be updated
until the SYSTS_UPGRADE_INDEX procedure is executed successfully.
Authorization
The privileges held by the authorization ID of the procedure must include the SYSTS_ADM role and the
DBADM authority.
Syntax
SYSTS_UPGRADE_INDEX ( 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.
CALL SYSPROC.SYSTS_UPGRADE_INDEX('en_US', ?)
Return Status = 0
Example 2: In the following example, the database was not enabled for text search in the older release of
the product. If a NULL value is set for message_locale, it means the system locale will be used. If the
system locale is not available then the default locale 'en_US' will be used.
CALL SYSPROC.SYSTS_UPGRADE_INDEX('', ?)
Example 3: In the following example, the Text Search catalog and the text search indexes were already
upgraded to the current version.
CALL SYSPROC.SYSTS_UPGRADE_INDEX('en_US', ?)
Return Status = 0
Example 4: In the following example, the Text Search catalog was not upgraded.
CALL SYSPROC.SYSTS_UPGRADE_INDEX('en_US', ?)
CIE0409E The Db2 Text Search catalog has not been upgraded to the current version.
Usage notes
• The SYSTS_UPGRADE_INDEX procedure is integrated into the DB2 UPGRADE DATABASE command to
perform upgrades for text search indexes. When issuing the DB2 UPGRADE DATABASE command , this
procedure will be executed as well. If the upgrade of text search indexes fails, the procedure must be
run manually.
• The SYSTS_UPGRADE_CATALOG procedure should be executed before SYSTS_UPGRADE_INDEX
procedure. The version value in the SYSIBMTS.TSDEFAULTS administrative view will not be updated
until the SYSTS_UPGRADE_INDEX procedure is executed successfully.
• Text Search administrative 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.
Authorization
One of the following authorities is required to execute the routine:
• DBADM authority
• WLMADM authority
Syntax
WLM_ENABLE_ADMISSION_CTRL ( newEnv )
Parameters
newEnv
An optional input argument of type VARCHAR(3) . If ‘YES’, NULL or no parameter is passed in,
preparation for the enablement of the adaptive workload manager will be initiated. If ‘NO’ is passed
in, preparation for the disablement of the adaptive workload manager will be initiated. A deactivation
and then reactivation of the database is required to complete the process.
Usage notes
The adaptive workload manager can only be enabled on databases where the registry variable
DB2_WORKLOAD has been set to ANALYTICS and WLM CPU shares are disabled. If these conditions are
not satisfied the stored procedure will fail with SQL1668, reason code 12.
After invocation of the WLM_ENABLE_ADMISSION_CTRL stored procedure the database must be
reactivated before any changes take effect. Until the database is reactivated, no changes are made to the
active database.
If the stored procedure is used to enable the adaptive workload manager the following changes will occur
when the database is next reactivated:
• The SYSDEFAULTMANAGESUBCLASS service subclass is dropped. Any WORKLOAD objects pointing to
the SYSDEFAULTMANAGEDSUBCLASS will be modified to point to the SYSDEFAULTUSERCLASS service
superclass. Any monitor settings defined on this service class (for example activity collection) are
implicitly removed since the subclass is dropped and must be manually redefined on the newly created
service subclasses if required.
• SYSMANAGEDQUERIES work class in the SYSDEFAULTUSERWCS work class set is dropped.
• SYSMAPMANAGEDQUERIES work action in the SYSDEFAULTUSERWAS work action set is dropped.
• The SYSDEFAULTCONCURRENT threshold is dropped
Syntax
WLM_CANCEL_ACTIVITY ( 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
cancelled. If the argument is null, no activity will be found and an SQL4702N with SQLSTATE 5U035 is
returned.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Example
An administrator can use the WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES table function to find
the application handle, unit of work ID and activity ID of an activity. To cancel an activity with application
handle 1, unit of work ID 2 and activity ID 3:
CALL WLM_CANCEL_ACTIVITY(1, 2, 3)
Usage notes
• If no activity can be found, an SQL4702N with SQLSTATE 5U035 is returned.
• 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.
• If the activity is successfully cancelled, an SQL4725N with SQLSTATE 57014 is returned to the
cancelled application.
• 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.
Authorization
One of the following authorities is required to execute the routine:
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Authorization
One of the following authorizations is required:
• DBADM authority
• WLMADM authority
Syntax
WLM_ALTER_MEMBER_SUBSET ( subset_name , subset_attributes ,
member_list )
Routine parameters
subset_name
An input argument of type VARCHAR(128) that specifies the name of the member subset object to be
altered. This is a one-part name. It is an SQL identifier (ordinary or delimited). The name must identify
a member subset which already exists in the current database (SQLSTATE 42704). This argument
cannot be NULL (SQLSTATE 42815).
subset_attributes
An input argument of type CLOB(8K) that enables you to alter one or more member subset attributes.
This parameter defaults to NULL. Subset attributes are specified as name value pairs using the
format:
Each subset attribute can be specified a maximum of one time (SQLSTATE 42613). Subset attribute
names are case sensitive. The subset attribute values are case insensitive unless otherwise noted.
The available subset attribute name tags are as follows:
'<enabled>value</enabled>'
Specifies whether this member subset will be considered when a connection request is assigned
to a member subset. This value can be either "yes" or "no". If not specified the current value is not
altered.
'<databaseAlias>value</databaseAlias>'
Replace the database alias that a client must connect to in order to be assigned to this member
subset. The name must conform to the naming conventions for local database aliases (SQLSTATE
2E000).
If the existing database alias was cataloged by a member subset operation it is uncataloged by
this command.
'<catalogDatabaseAlias>value</catalogDatabaseAlias>'
Specifies whether the procedure should catalog the new database alias specified in the
databaseAlias attribute. This value can be either "yes" or "no". When this attribute is specified a
new database alias attribute must also be provided (SQLSTATE 530AA).
If the value of this attribute is "yes" the new database alias specified in the databaseAlias
attribute must not already be cataloged (SQL1005N). If the value of this attribute is "no" the new
database alias specified in the databaseAlias attribute must already be cataloged (SQLSTATE
42705).
'<memberPriorityBasis>value</memberPriorityBasis>'
Specifies what information should be used when calculating the relative member priorities in the
member subsets server list. This value can be either "load" or "equalPriority". If not specified, the
current value is not altered.
The value "load" indicates that the member priorities in the member subsets server list will be
based on the relative load of each member. The relative load is calculated based on the average
CPU load and average page swap rate. This value can be specified only in a Db2 pureScale
instance (SQLSTATE 530AA).
The value "equalPriority" indicates that the member priority in the member subsets server list for
each active member will be 101.
'<inclusiveSubset>value</inclusiveSubset>'
Specifies whether all members in the instance will be included in the member subset's server list
for high availability (HA) purposes when no other member of the subset is online.
This attribute can be specified only in a Db2 pureScale instance (SQLSTATE 530AA). When
specified the value can be either "yes" or "no". If not specified, the current value is not altered.
ADD member-number
DROP member-number
Each member number can be specified a maximum of one time (SQLSTATE 42613). If the ADD token
is specified, the member must not already be included in the member subset (SQLSTATE 42613). If
the ALTER or DROP token is specified, the member must already be included in the member subset.
The member number must be defined in the instance (SQLSTATE 42729). The last primary member in
a member subset cannot be dropped (SQLSTATE 530AB).
failover_priority_number
In a Db2 pureScale environment, the failover_priority_number argument can be specified with
member_list. Use failover_priority_number with member_list to specify a failover priority for the
members that are being added or altered in the member subset. The parameter defaults to 0.
Each subset must have at least one member with FAILOVER_PRIORITY set to 0. The value for
failover_priority_number can be 0 - 254 (SQLSTATE 42815).
Usage notes
• As an autonomous procedure, WLM_ALTER_MEMBER_SUBSET executes in its own transaction scope.
• When WLM_ALTER_MEMBER_SUBSET successfully completes, it will commit the work performed
within the procedure, but if it is unsuccessful, the procedure rolls back any work performed.
Examples
1. Add member 3 to the member subset MY_SUBSET.
CALL SYSPROC.WLM_ALTER_MEMBER_SUBSET('MY_SUBSET',
'<memberPriorityBasis>equalPriority</memberPriorityBasis>', NULL)
5. Replace the current database alias subset attribute from MY_SUBSET with NEWALIAS.
CALL SYSPROC.WLM_ALTER_MEMBER_SUBSET('MY_SUBSET',
'<databaseAlias>NEWALIAS</databaseAlias>', NULL)
Authorization
One of the following authorizations is required:
• DBADM authority
• WLMADM authority
Syntax
WLM_CREATE_MEMBER_SUBSET ( subset_name , subset_attributes ,
member_list )
Routine parameters
subset_name
An input argument of type VARCHAR(128) that specifies the name of the member subset object to be
created. This is a one-part name. It is an SQL identifier (ordinary or delimited). The name must not
identify a member subset which already exists in the current database (SQLSTATE 42710). The name
must not begin with the characters 'SYS' (SQLSTATE 42939). This argument cannot be NULL
(SQLSTATE 42815).
subset_attributes
An input argument of type CLOB(8K) that enables you to specify one or more member subset
attributes. This parameter cannot be NULL (SQLSTATE 42815). Subset attributes are specified as
name value pairs using the format:
Each subset attribute can be specified a maximum of one time (SQLSTATE 42613). Subset attribute
names are case sensitive. The subset attribute values are case insensitive unless otherwise noted.
The available subset attribute name tags are as follows:
'<enabled>value</enabled>'
Specifies whether this member subset will be considered when a connection request is assigned
to a member subset. This value can be "yes", “wlb” or "no". If not specified it defaults to "yes".
( member-number )
Each member number can be specified a maximum of one time (SQLSTATE 42613). The member
number must be defined in the instance (SQLSTATE 42729).
Examples
1. Create a member subset in a Db2 pureScale instance for connections to the database alias PSALIAS.
The PSALIAS database alias does not exist and will be cataloged by the
WLM_CREATE_MEMBER_SUBSET procedure.
CALL SYSPROC.WLM_CREATE_MEMBER_SUBSET(
'PURESCALE_SUBSET',
'<databaseAlias>PSALIAS</databaseAlias>',
'(0, 1)' )
2. Create a member subset in a partitioned database environment for connections to the database alias
DPFALIAS. The DPFALIAS database alias does not exist and will be cataloged by the
WLM_CREATE_MEMBER_SUBSET procedure.
The server list for the member subset is to include members 100 and 200 only.
CALL SYSPROC.WLM_CREATE_MEMBER_SUBSET(
'DPF_SUBSET',
'<databaseAlias>DPFALIAS</databaseAlias>',
'(100, 200)' )
3. Create a member subset in a Db2 pureScale instance for connections to the database alias OLTPDB.
The OLTPDB database alias exists prior to executing the WLM_CREATE_MEMBER_SUBSET procedure.
The server list for the member subset is to include members 1 and 2 for workload balancing usage and
all other members for automatic client rerouting purposes.
CALL SYSPROC.WLM_CREATE_MEMBER_SUBSET(
'OLTP_SUBSET',
'<catalogDatabaseAlias>no</catalogDatabaseAlias>
<databaseAlias>OLTPDB</databaseAlias>',
'(1, 2)' )
4. Create a member subset in a Db2 pureScale instance for connections to the database alias EQUALDB.
The EQUALDB database alias does not exist and will be cataloged by the
WLM_CREATE_MEMBER_SUBSET procedure.
The server list for the member subset is to include members 0 and 1 only. The member priority in the
server list are to be equivalent for all active members.
CALL SYSPROC.WLM_CREATE_MEMBER_SUBSET(
'EQUAL_SUBSET',
'<memberPriorityBasis>equalPriority</memberPriorityBasis>
<inclusiveSubset>no</inclusiveSubset>
<databaseAlias>EQUALDB</databaseAlias>',
'(0, 1)' )
5. Alter a member subset to enable work load balancing ( transaction level load balancing) on a client or
driver, if not explicitly disabled by an application.
Authorization
One of the following authorizations is required:
• DBADM authority
• WLMADM authority
Syntax
WLM_DROP_MEMBER_SUBSET ( subset_name )
Routine parameters
subset_name
An input argument of type VARCHAR(128) that specifies the name of the member subset object to be
dropped. This is a one-part name. It is an SQL identifier (ordinary or delimited). The name must
identify a member subset which already exists in the current database (SQLSTATE 42704). This
argument cannot be NULL (SQLSTATE 42815).
Usage notes
• As an autonomous procedure, WLM_DROP_MEMBER_SUBSET executes in its own transaction scope.
• When WLM_DROP_MEMBER_SUBSET successfully completes, it will commit the work performed within
the procedure, but if it is unsuccessful, the procedure rolls back any work performed.
Example
Drop the member subset MY_SUBSET.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Syntax
WLM_GET_CONN_ENV ( application_handle )
Parameters
application_handle
An input argument of type BIGINT that specifies the application handle for the connection for which
information is to be returned. You can use a value of NULL to indicate the connection on which the
procedure was invoked.
Information returned
Usage notes
The WLM_GET_CONN_ENV table function provides maximum flexibility for formatting output because it
returns WLM environment information for a connection as an XML document. The output can be parsed
directly by an XML parser, or it can be converted to relational format by the XMLTABLE function.
The schema for the XML document that is returned in the DETAILS column is available in the file sqllib/
misc/DB2MonRoutines.xsd. Further details can be found in the file sqllib/misc/
DB2MonCommon.xsd.
Example
The following query checks whether activities are being collected for the current connection.
SELECT application_handle,
xmlparse(document details preserve whitespace)
FROM TABLE (
WLM_GET_CONN_ENV(
cast(NULL as bigint))
) connenv
APPLICATION_HANDLE DETAILS
-------------------- ------------------------------------------------------
7 <wlm_conn_env
xmlns=http://www.ibm.com/xmlns/prod/db2/mon
release="9070100">
<collectactdata>NONE</collectactdata>
<collectactpartition>COORDINATOR</collectactpartition>
<collectsectionactuals>NONE</collectsectionactuals>
</wlm_conn_env>
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
WLM_GET_SERVICE_CLASS
_WORKLOAD_OCCURRENCES - list workload occurrences
The WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES function returns the list of all workload
occurrences running in a specified service class on a particular member. A workload occurrence is a
specific database connection whose attributes match the definition of a workload and hence is associated
with or assigned to the workload.
Refer to Table 213 on page 1097 for a complete list of information that can be returned.
Syntax
WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES ( service_superclass_name
, service_subclass_name , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Example
If an administrator wants to see what workload occurrences are running on the system as a whole, the
administrator can call the WLM_GET_SERVICE_CLASS_WORKLOAD_OCCURRENCES function by
specifying a null value or an empty string for service_superclass_name and service_subclass_name and
-2 for member:
If the system has four database members and is currently running two workloads, the previous query
produces results such as the following ones:
Usage note
The parameters are, in effect, ANDed together. That is, if you specify conflicting input parameters, such as
a service superclass SUP_A and a subclass SUB_B such that SUB_B is not a subclass of SUP_A, no rows
are returned.
Note: Statistics reported for the workload occurrence (for example, coord_act_completed_total) are reset
at the beginning of each unit of work when they are combined with the corresponding workload statistics.
Information returned
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
WLM_GET_WORKLOAD
_OCCURRENCE _ACTIVITIES - Return a list of activities
The WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES function returns the list of all activities that were
submitted by the specified application on the specified member and have not yet been completed.
The functionality of WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES is identical to the functionality of
MON_GET_ACTIVITY. Although the functionality for these two routines is the same, the authorization is
not necessarily the same. See MON_GET_ACTIVITY for syntax, parameters, information returned, usage
notes, and examples.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
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 you specify NULL,
the value remains unchanged. If you specify an empty string, which is the default value, 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 you
specify NULL, the value remains unchanged. If you specify an empty string, which is the default value,
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 you
specify NULL, the value remains unchanged. If you specify an empty string, which is the default value,
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 you
specify NULL, the value remains unchanged. If you specify an empty string, which is the default value,
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 you specify NULL, the value remains unchanged. The values are as follows:
SYSDEFAULTADMWORKLOAD
Specifies that the database connection will be assigned to SYSDEFAULTADMWORKLOAD, enabling
users with ACCESSCTRL, DATAACCESS, DBADM, SECADM, or WLMADM authority to bypass the
normal workload evaluation.
AUTOMATIC
Specifies that the database connection will be assigned to a workload chosen by the workload
evaluation that is performed automatically by the server.
Note: The client_workload argument is case sensitive.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
Examples
The following procedure call sets the user ID, workstation name, application name, accounting string, and
workload assignment mode for the client:
The following procedure call sets the user ID to db2user2 for the client without setting the other client
attributes:
The following procedure call resets the user ID for the client to blank without modifying the values of the
other client attributes:
Usage notes
If the input that you specify for any procedure parameter exceeds its specified field length, the input field
is truncated and the procedure runs using the truncated inputs.
Input fields containing single quotations are not supported and result in an error.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• WLMADM authority
Parameters
application_handle
An input argument of type BIGINT that specifies the application handle whose connection
environment is to be modified. The application handle specified must refer to an existing application
(otherwise, SQLSTATE 5U002 is returned). You can use a value of NULL to indicate that the
connection whose environment is to be changed is the connection on which the procedure was
invoked.
settings
An input argument of type CLOB(8K) that enables you to specify one or more monitor settings.
Settings are specified as name value pairs using the format:
Each setting can be specified a maximum of one time. Setting names are case sensitive. A change to a
setting takes effect on the next statement executed; it has no effect on statements already in
progress.
The available setting name tags are as follows.
• '<collectactdata>value</collectactdata>'
Specifies what activity data should be collected by the activity event monitor. The possible values
are (variations in spaces between words are supported):
Value Description
NONE Activity data should not be collected
WITHOUT DETAILS Data about each activity is sent to any active
activities event monitor when the activity
completes execution. Details about statement,
compilation environment, and section
environment data are not sent.
WITH DETAILS Statement and compilation environment data is
sent to any active activities event monitor, for
those activities that have them. Section
environment data is not sent.
Example
The following examples both enable activity collection, without details, on the coordinator partition for
the current connection:
CALL WLM_SET_CONN_ENV(NULL,'<collectactdata>WITHOUT
DETAILS</collectactdata><collectactpartition>COORDINATOR
</collectactpartition>')
The next example enables collection of activity data with section environment data and section actuals ,
but no data values, on all partitions for the current connection:
The following example disables collection of activity data for the current connection.
Usage notes
The collectactdata setting only controls activity data collection at the connection level . An activity might
have multiple activity data collection controls applied to it, for example, the connection might be mapped
to a service class where the COLLECT ACTIVITY DATA clause has been applied. In a situation where
multiple activity data collection controls are applied, the effective setting is the combination of all the
settings. For example:
1. The connection level control is activity data without details.
Authorization
One of the following authorities is required to execute the routine:
• DBADM authority
• WLMADM authority
Syntax
Parameters
application_handle
An input argument of type BIGINT that specifies the application handle for the connection for which
the session priority is to be set. You can use a value of NULL to indicate the connection on which the
procedure was invoked.
priority
An input argument of type VARCHAR(32) that specifies the session priority level. Valid levels are
'LOW', 'MEDIUM', 'HIGH', 'CRITICAL' or you can set the session back to its default setting by
specifying 'DEFAULT'.
Example
An application submits a mix of regular and high priority queries. When the high priority queries are
submitted it is desirable to minimize the chance of those queries being queued behind other lower priority
work. Before the high priority queries are submitted, the application issues the following stored
procedure call so that the activities will be run as high priority.
This example assumes that the application has sufficient authority to invoke the
WLM_SET_SESSION_PRIORITY stored procedure.
Usage notes
Use the WLM_SET_SESSION_PRIORITY stored procedure to raise or lower the priority of work submitted
by a connection. Higher priority work will receive a greater share of admission resources by the adaptive
workload manager. Priority changes made by the stored procedure take effect immediately and will
elevate or reduce the priority of any existing queued activities for the connection.
Any session priority value set by the WLM_SET_SESSION_PRIORITY stored procedure has a higher
precedence than a priority set on WORKLOAD object. For example, if an application is mapped to a
workload with a LOW priority, and the stored procedure is called with a priority value of HIGH, any current
and future activities submitted by the connection will run with a HIGH priority.
Related information
Session priority
ALTOBJ
The ALTOBJ procedure parses an input CREATE TABLE statement that serves as the target data definition
language (DDL) for an existing table that is to be altered.
The procedure backs up the data of the table being altered, then drops the original table and creates a
new version using the DDL statement; the final step loads the stored data back into the new table.
This procedure supports the following alter table operations and maintains recoverable dependencies:
• Renaming a column
• Increasing or decreasing the size of a column
• Altering a column type and transforming existing data using scalar functions
• Changing the precision or the scale of decimal values
• Changing the default value of a column
• Changing the nullability attribute of a column to nullable
• 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.
'UNDO'
Specifies that any changes made by the alter table operation are to be undone, in case a rollback
operation cannot recover errors that might have occurred. This mode is only possible if the
original table and any generated scripts have not been deleted. In this mode, the alter-id
parameter must be specified as generated in a previous ALTOBJ operation and cannot have a
value of -1, otherwise SQL0443N is returned.
'FINISH'
Specifies that the renamed original table is to be dropped.
Authorization
DBADM authority and authorization to execute the LOAD command are required to execute this function.
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:
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.
Usage notes
Although the procedure drops and re-creates the table, the user who created the original table will
remain as the table definer. However, an audit will show that the table has been dropped and re-created
by the user running the procedure.
This procedure does not support the following alter table operations:
• Altering materialized query tables (MQTs) is not supported. Altering a table which contains an MQT is
supported.
• Altering typed tables is not supported.
• Altering a remote table using a nickname is not supported.
• Column sequence cannot be reordered.
• Adding and removing, or renaming and removing columns in one call to the procedure is not supported,
but adding and renaming columns is supported. This is because the only way to indicate how the table
is to be altered is by the use of the target DDL, rather than column matching information. The following
Syntax
COMPILATION_ENV ( compilation-env )
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
Example 3: Display the compilation environment for a specific statement in the package cache.
1. Obtain the executable ID, which is used to identify the statement of interest, using the following
statement:
2. Investigate the compilation environment for the statement (identified using the executable ID) and
format the compilation environment using the COMPILATION_ENV table function. The following
statement is an example of how this can be done:
1 2
------------------------------ --------------------------------------------------
ISOLATION CS
QUERY_OPTIMIZATION 5
DEGREE 1
SQLRULES DB2
9 record(s) selected.
Information returned
Table 215. Elements of a compilation environment returned by the COMPILATION_ENV table function
Element name Description
ISOLATION The isolation level passed to the SQL compiler. The value is obtained
from either the CURRENT ISOLATION special register or the
ISOLATION bind option of the current package.
QUERY_OPTIMIZATION The query optimization level passed to the SQL compiler. The value
is obtained from either the CURRENT QUERY OPTIMIZATION special
register or the QUERYOPT bind option of the current package.
DEGREE The requested degree of intra-parallelism passed to the SQL
compiler. The value is obtained from either the CURRENT DEGREE
special register or the DEGREE bind option of the current package.
SQLRULES The requested SQL statement behaviors passed to the SQL compiler.
The value is derived from the setting of the LANGLVL bind option of
the current package. The possible values are 'DB2' or 'SQL92'.
REFRESH_AGE The allowable data latency passed to the SQL compiler. The value is
obtained from either the CURRENT REFRESH AGE special register or
the REFRESHAGE bind option of the current package.
SCHEMA The default schema passed to the SQL compiler. The value is
obtained from either the CURRENT SCHEMA special register or the
QUALIFIER bind option of the current package.
PATH The function path passed to the SQL compiler. The value is obtained
from either the CURRENT PATH special register or the FUNC_PATH
bind option of the current package.
TRANSFORM_GROUP The transform group information passed to the SQL compiler. The
value is obtained from either the CURRENT DEFAULT TRANSFORM
GROUP special register or the TRANSFORMGROUP package bind
option.
MAINTAINED_TABLE An indicator of what table types can be considered for optimization,
_TYPE passed to the SQL compiler. The value is obtained from the
CURRENT MAINTAINED TABLE TYPES FOR OPTIMIZATION special
register.
Authorization
One of the following authorizations is required:
• SELECT privilege on the CONTACTGROUPS administrative view
• CONTROL privilege on the CONTACTGROUPS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Retrieve all contact group lists.
7 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the CONTACTS administrative view
• CONTROL privilege on the CONTACTS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Retrieve all contacts.
Usage note
The DAS must have been created and be running.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the DB_HISTORY administrative view
• CONTROL privilege on the DB_HISTORY administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Usage note
When a data partitioned table is reorganized, one record for each reorganized data partition is returned. If
only a specific data partition of a data partitioned table is reorganized, only a record the for the partition is
returned.
1 record(s) selected.
Information returned
Table 218. Information returned by the DB_HISTORY administrative view
EID BIGINT Number that uniquely identifies an entry in the history file.
SEQNUM SMALLINT Positive integer which identifies the various parts of an image, such
as sequences or sessions.
NUM_LOG_ELEMS INTEGER Number of log streams that will be returned in the lists of log stream
data in the FIRSTLOG and LASTLOG columns.
FIRSTLOG VARCHAR(4000) Name of the earliest transaction log associated with an event.
• In Db2 pureScale environments, where one or more log streams
can exist, the entry uses the following format:
(<log_stream_id>: <log_file_name> ,
<log_stream_id>:
<log_file_name> , ...)
(<log_file_name>)
LASTLOG VARCHAR(4000) Name of the latest transaction log associated with an event.
• In Db2 pureScale environments, where one or more log streams
can exist, the entry uses the following format:
(<log_stream_id>: <log_file_name> ,
<log_stream_id>: <log_file_name> , ...)
(<log_file_name>)
TBSPNAMES CLOB(5 M) Names of the table spaces associated with a logged event.
OPERATION CHAR(1) Operation identifier. See Table 219 on page 1117 for possible
values.
OPERATIONTYPE CHAR(1) Action identifier for an operation. See Table 219 on page 1117 for
possible values.
OBJECTTYPE CHAR(1) Identifier for the target object of an operation. The possible values
are: D for full database, I for index, P for table space, R for
partitioned table, and T for table.
LOCATION VARCHAR(255) Full path name for files, such as backup images or load input files,
that are associated with logged events. In the case of CLI LOAD or
LOAD from CURSOR, the location is an SQL statement.
DEVICETYPE CHAR(1) Identifier for the device type associated with a logged event. This
field determines how the LOCATION field is interpreted:
• A for TSM
• C for client
• D for disk
• F for snapshot backup
• K for diskette
• L for local
• N (generated internally by the database system)
• O for other (for other vendor device support)
• P for pipe
• Q for cursor
• R for remote fetch data
• S for server
• T for tape
• U for user exit
• X for X/Open XBSA interface
ENTRY_STATUS CHAR(1) Identifier for the status of an entry in the history file:
• A for active
• D for deleted (future use)
• E for expired, I for inactive
• N for not yet committed
• Y for committed or active
SQLCABC INTEGER Length of the SQLCA, as it appears in the SQLCABC field of the
SQLCA.
SQLCODE INTEGER SQL return code, as it appears in the SQLCODE field of the SQLCA.
SQLERRML SMALLINT Length indicator for SQLERRMC, as it appears in the SQLERRML field
of the SQLCA.
SQLERRMC VARCHAR(70) Contains one or more tokens, separated by X'FF', as they appear in
the SQLERRMC field of the SQLCA. These tokens are substituted for
variables in the descriptions of error conditions.
SQLERRD1 INTEGER See "SQLCA (SQL communications area)" in SQL Reference Volume
1.
SQLERRD2 INTEGER See "SQLCA (SQL communications area)" in SQL Reference Volume
1.
SQLERRD3 INTEGER See "SQLCA (SQL communications area)" in SQL Reference Volume
1.
SQLERRD4 INTEGER See "SQLCA (SQL communications area)" in SQL Reference Volume
1.
SQLERRD5 INTEGER See "SQLCA (SQL communications area)" in SQL Reference Volume
1.
SQLERRD6 INTEGER See "SQLCA (SQL communications area)" in SQL Reference Volume
1.
SQLWARN VARCHAR(11) A set of warning indicators, each containing a blank or 'W'. See
"SQLCA (SQL communications area)" in SQL Reference Volume 1.
SQLSTATE VARCHAR(5) A return code that indicates the outcome of the most recently
executed SQL statement, as it appears in the SQLSTATE field of the
SQLCA.
U Unload None
X Archive logs Operation types are:
• F = fail archive path
• M = mirror log path
• N = forced truncation via ARCHIVE
LOG command
• P = primary log path
• 1 = first log archive method
• 2 = second log archive method
Authorization
One of the following authorizations is required:
• SELECT privilege on the DBPATHS administrative view
• CONTROL privilege on the DBPATHS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
The following statement retrieves all database paths:
5 record(s) selected.
Syntax
ADMIN_LIST_DB_PATHS ( )
Authorization
One of the following authorizations is required:
Example
The ADMIN_LIST_DB_PATHS table function can be invoked as follows:
DBPARTITIONNUM TYPE
-------------- ----------------------
2 LOGPATH
2 DB_STORAGE_PATH
2 TBSP_DIRECTORY
2 TBSP_CONTAINER
2 LOCAL_DB_DIRECTORY
2 DBPATH
2 DBPATH
0 LOGPATH
0 DB_STORAGE_PATH
0 TBSP_DIRECTORY
0 TBSP_CONTAINER
0 LOCAL_DB_DIRECTORY
0 DBPATH
0 DBPATH
1 LOGPATH
1 DB_STORAGE_PATH
1 TBSP_DIRECTORY
1 TBSP_CONTAINER
1 LOCAL_DB_DIRECTORY
1 DBPATH
1 DBPATH
PATH
--------------------------------------------------
/home/sun/sun/NODE0002/SQL00001/LOGSTREAM0002/
/home/sun/
/home/sun/tablespace/sms/sms2/
/home/sun/tablespace/dms/dms2
/home/sun/sun/NODE0002/sqldbdir/
/home/sun/sun/NODE0002/SQL00001/
/home/sun/sun/NODE0002/SQL00001/MEMBER0002/
/home/sun/sun/NODE0000/SQL00001/LOGSTREAM0000/
/home/sun/
/home/sun/tablespace/sms/sms0/
/home/sun/tablespace/dms/dms0
/home/sun/sun/NODE0000/sqldbdir/
/home/sun/sun/NODE0000/SQL00001/
/home/sun/sun/NODE0000/SQL00001/MEMBER0000/
/home/sun/sun/NODE0001/SQL00001/LOGSTREAM0001/
/home/sun/
/home/sun/tablespace/sms/sms1/
/home/sun/tablespace/dms/dms1
/home/sun/sun/NODE0001/sqldbdir/
/home/sun/sun/NODE0001/SQL00001/
/home/sun/sun/NODE0001/SQL00001/MEMBER0001/
If the storage library performing the split mirror operation treats files and directories on raw devices
differently than those on regular file systems, you can use the following query to obtain the list for all
locations on raw devices:
Information returned
Table 220. Information returned by the DBPATHS administrative view and the ADMIN_LIST_DB_PATHS
table function
Column name Data type Description
DBPARTITIONNUM SMALLINT dbpartitionnum - Database
partition number monitor
element
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 221 on page 1121 for a list
of possible return values.
PATH VARCHAR(5000) Path to location where the
database manager has a file or
directory located. If the path
ends with the file system
delimiter ('/' on UNIX
environments, '\' on Windows
environments), the path points to
a directory.
• For table spaces using automatic storage, both used and unused storage paths are returned. You
require the unused automatic storage paths if you restore by using a split mirror backup.
Consider the following example. A split mirror backup is taken on a production system. After the backup
is completed, 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 database by using the split mirror backup.
At this point, it is necessary to roll forward the logs from the production database. To roll forward the
logs, all of the automatic storage paths are required, because all automatic storage paths are now in
use.
• Table space containers that are managed by automatic storage are not returned individually. Instead,
they are reflected in the automatic storage path column.
• The automatic storage paths are returned once per database partition.
• The values returned for the logpath and mirrorlogpath configuration parameters are the values
stored in memory. Changed values that are stored on disk, which are applicable only after a database
restart, are not returned.
• If you use output from the SELECT * FROM SYSIBMADM.DBPATHS query to create a db2relocatedb
command configuration file (a file containing the configuration information that is necessary for
relocating a database), you must modify the DBPATH output appropriately before you can use it in the
configuration file.
For example, consider the following DBPATH output:
/storage/svtdbm3/svtdbm3/NODE0000/SQL00001/
You can use this output to specify the value of the DB_PATH parameter in a db2relocatedb command
configuration file, as follows:
DB_PATH=/storage/svtdbm3,/storage_copy2/svtdbm3
• The LOCAL_DB_DIRECTORY path might contain information belonging to multiple databases. Because
each database that you create in the same directory does not have its own sqldbdir file, ensure that
the target system to which you copy files does not have any databases already in that path.
• If two or more databases share at least one automatic storage path, the split mirror operation for one of
these databases might affect more than one database, causing I/O problems for the databases that you
did not intend to split.
• The DB_STORAGE_PATH type includes all storage paths from all defined storage groups. If a storage
path is used by multiple storage groups or is specified multiple times in the same storage group, one
record is returned for each occurrence of the path in a storage group.
Restriction
You cannot call the administrative view when the database is in WRITE SUSPEND mode. Also, you must
ensure that the physical layout of the database does not change between the invocation of the view and
the activation of WRITE SUSPEND mode, which is needed to perform a split mirror operation. You might
not be able to restore from the split mirror backup image if, for example, the table space layout changed
in that time.
Authorization
To execute the procedure, SYSMON authority is required, in addition to one of the following
authorizations:
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• EXECUTE privilege on the GET_DBSIZE_INFO, WLM_SET_CONN_ENV, MON_GET_CONTAINER, and
MON_GET_TABLESPACE routines
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 refresh-window, is used to determine when the
cached values in the SYSTOOLS.STMG_DBSIZE_INFO table need to be refreshed.
dbsize
An output parameter of type BIGINT that returns the size of the database (in bytes). The database
size is calculated as follows: dbsize = sum (used_pages * page_size) for each table space (SMS &
DMS).
dbcapacity
An output parameter of type BIGINT that returns the database capacity (in bytes). This value is not
available on partitioned database systems. The database capacity is calculated as follows: dbcapacity
= SUM (DMS usable_pages * page size) + SUM (SMS container size + file system free size per
container). If multiple SMS containers are defined on the same file system, the file system free size is
included only once in the calculation of capacity.
refresh-window
An input argument of type INTEGER that specifies the number of minutes until the cached values for
database size and capacity are to be refreshed. Specify -1 for the default refresh window of 30
minutes. A refresh window of 0 forces an immediate refreshing of the cached values.
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
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.
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.
Return Status = 0
Authorization
One of the following authorizations is required:
• SELECT privilege on the NOTIFICATIONLIST administrative view
• CONTROL privilege on the NOTIFICATIONLIST administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
The NOTIFICATIONLIST administrative view returns the list of contacts and contact groups that are
notified about the health of an instance.
The following is an example of output for this query.
NAME TYPE
------------...------- -------
group3 GROUP
user4 CONTACT
group3 GROUP
3 record(s) selected.
Information returned
Syntax
PD_GET_DIAG_HIST ( facility , rectype , impact , start_time ,
end_time , member )
Information returned
DBNAME VARCHAR(128) The name of the database being accessed while this
message was created.
EDU_ID BIGINT edu_ID - Engine dispatchable unit ID monitor element
EDUNAME VARCHAR(64) The name of the engine Dispatched Unit that created
this message.
PID BIGINT The operating system process identifier that created
this message.
PROCESS_NAME VARCHAR(255) The operating system process name that created this
message.
TID BIGINT The thread numeric identifier that created this
message.
APPLNAME VARCHAR(255) The name of the client application that initiated the
connection, if it is available.
APPL_ID VARCHAR(64) appl_id - Application ID monitor element
APPLHANDLE VARCHAR(9) A system-wide unique identifier for the application that
initiated the connection when available. This is
synonymous to agent ID. The identifier consists of the
coordinating member number and a 16-bit counter
separated by a '-'. The format is as follows: 'nnn-xxxxx'
AUTH_ID VARCHAR(30) auth_id - Authorization ID monitor element
PRODUCT VARCHAR(50) The name of the product that created the message. For
example 'Db2 Common'.
COMPONENT VARCHAR(255) The name of the component that created the message.
FUNCTION VARCHAR(255) The name of the function that generated the message.
OBJNAME VARCHAR(255) The name of the object the event relates to, if it is
available.
OBJNAME_QUALIFIER VARCHAR(255) Additional information about the object, if it is
available.
EVENTSTACK CLOB(16K) The logical event stack at the point the record was
logged when applicable.
CALLSTACK CLOB(16K) The operating system stack dump for the thread that
generated this record when applicable.
DUMPFILE CLOB(5000) The name of the secondary dump file associated with
the log record when applicable. This is a fully qualified
path to a file or directory where additional information
related to the message can be retrieved.
FULLREC CLOB(16K) Formatted text version of the entire record. This
section also contains additional DATA fields.
MEMBER SMALLINT member - Database member monitor element
HOSTNAME VARCHAR(255) hostname - Host name
Usage note
The PD_GET_DIAG_HIST table function requires that the associated database has a temporary table
space with minimum page size of 8K. If the page size is less than 8K, the function will return an
SQL1585N error message.
Examples
Example 1: Retrieve records from a given facility.
2 record(s) selected.
12 record(s) selected.
Authorization
One of the following authorizations is required:
• SELECT privilege on the PDLOGMSGS_LAST24HOURS administrative view
• CONTROL privilege on the PDLOGMSGS_LAST24HOURS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
Example
Get all critical log messages logged in the last 24 hours, ordered by most recent.
4 record(s) selected.
Syntax
PD_GET_LOG_MSGS ( oldest_timestamp , member )
Information returned
Note: In a multi-member 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 224. 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.
INSTANCENAME VARCHAR(128) Name of the instance that
generated the message.
DBPARTITIONNUM SMALLINT dbpartitionnum - Database
partition number monitor
element
DBNAME VARCHAR(128) The database on which the error
or event occurred.
... MSG
... ----------------------------------------------------------...--
... ADM5502W The escalation of "143" locks on table
... "SYSIBM .SYSINDEXAUTH" to lock intent "X" was successful.
... ADM5502W The escalation of "144" locks on table
... "SYSIBM .SYSINDEXES" to lock intent "X" was successful.
... ADM5502W The escalation of "416" locks on table
... "SYSIBM .SYSINDEXCOLUSE" tolock intent "X" was successful.
... ADM5500W Db2 is performing lock escalation. The total
... number of locks currently held is "1129", and the target
... number of locks to hold is "564".
... ADM7506W Database quiesce has been requested.
... ADM7507W Database quiesce request has completed successfully.
... ADM7510W Database unquiesce has been requested.
... ADM7509W Database unquiesce request has completed successfully.
... ADM4500W A package cache overflow condition has occurred. There
... is no error but this indicates that the package cache has
... exceeded the configured maximum size. If this condition persists,
... you may want to adjust the PCKCACHESZ DB configuration parameter.
Example 2: Retrieve all critical errors logged on instance XYZ for database partition 0 in the last day,
sorted by most recent.
2 record(s) selected.
Example 3: Retrieve messages written by database processes servicing application with application ID of
*LOCAL.DB2.050927195337, over the last day.
TIMESTAMP MSG
-------------------------- ------------------------------------------
...
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.
4 record(s) selected.
... 4
... ------------------------------- -------------------
... ADM7513W Database manager has started.
...
... ADM7513W Database manager has started.
...
... ADM7513W Database manager has started.
...
... ADM7513W Database manager has started.
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
Authorization
• SELECT privilege on catalog tables.
• EXECUTE privilege on the REORGCHK_IX_STATS procedure.
Example
CALL SYSPROC.REORGCHK_IX_STATS('T','JESCOTT.EMPLOYEE')
Usage note
The procedure uses the SYSTOOLSTMPSPACE table space. If SYSTOOLSTMPSPACE does not already
exist, the procedure will create this table space.
Information returned
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', use this argument to specify one of the following values:
• A fully qualified table name
• The value ALL for all tables
• The value USER for all user-defined tables
• The value SYSTEM for system-defined tables
If scope has a value of 'S', use this argument to specify a schema name.
Authorization
• SELECT privilege on catalog tables.
• EXECUTE privilege on the REORGCHK_TB_STATS procedure.
Example
CALL SYSPROC.REORGCHK_TB_STATS('T','JESCOTT.EMPLOYEE')
Usage note
The procedure uses the SYSTOOLSTMPSPACE table space. If SYSTOOLSTMPSPACE does not already
exist, the procedure will create this table space.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the routine
SECADM authority is required to grant EXECUTE privilege on the
SET_MAINT_MODE_RECORD_NO_TEMPORALHISTORY procedure. EXECUTE privilege WITH GRANT
OPTION cannot be granted for this routine (SQLSTATE 42501).
Syntax
SET_MAINT_MODE_RECORD_NO_TEMPORALHISTORY ( )
Usage notes
• Disabling the recording of temporal history for a system-period temporal table with the
SET_MAINT_MODE_RECORD_NO_TEMPORALHISTORY procedure lasts for the duration of the current
session.
Example
Set the internal option to disable recording of temporal history for a system-period temporal table and
allow values to be specified for the special temporal columns.
call SYSPROC.SET_MAINT_MODE_RECORD_NO_TEMPORALHISTORY()
Syntax
SQLERRM ( msgid , tokens , token_delimiter , locale ,
shortmsg )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
The data type of the result is VARCHAR(32672).
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))
1
--------------------------------------------------------------...--
SQL0551N "AYYANG" does not have the privilege to perform operation
"UPDATE" on object "SYSCAT.TABLES"
1
---------------------------------------------------------------...--
SQLSTATE 42501: The authorization ID does not have the privilege to
perform the specified operation on the identified object.
1
------------------------------------------------------------...--
SQL1001N "<name>" is not a valid database name.
Explanation:
User Response:
sqlcode : -1001
sqlstate : 2E000
Syntax
SQLERRM ( sqlcode )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
The data type of the result is VARCHAR(32672).
Example
Retrieve the short message for SQLCODE SQL0551N.
1
--------------------------------------------------------------...--
SQL0551N "" does not have the privilege to perform operation
"" on object "".
SYSINSTALLOBJECTS
The SYSINSTALLOBJECTS procedure creates, drops, verifies, or migrates 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:
• 'DB2AC' for autonomous computing (health monitor)
• 'STMG_DBSIZE_INFO' for storage management
• 'OPT_PROFILES' for creating the optimization profile table
• 'POLICY' for policy (tables and triggers)
• 'EXPLAIN' for creating or migrating explain tables
• 'INGEST' for creating the restart table used by the ingest utility
• 'REPL_MQT' for creating the latency table for shadow tables
• 'GEO' for creating or updating Spatial Analytics artifacts
action
An input argument of type CHAR(1) that specifies the action that is to be taken:
C
Create objects.
D
Drop objects.
V
Verify objects.
Authorization
One of the following authorities is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
• Migrate all explain tables.
• Verify objects that are used for autonomous computing (health monitor).
SQL0438N Application raised error or warning with diagnostic text: "DB2AC INVALID".
SQLSTATE=3900
Deprecated Replacement
Deprecated routine or view since New routine or view available since
“APPL_PERFORMANCE administrative view - Retrieve Version 10.5 “MON_CONNECTION_SUMMARY - Retrieve metrics for all
percentage of rows selected for an application” on page connections” on page 372
1197
“APPLICATIONS administrative view - Retrieve connected Version 10.5 “MON_GET_CONNECTION table function - Get connection
database application information” on page 1199 metrics” on page 532
“BP_HITRATIO administrative view - Retrieve bufferpool Version 10.5 “MON_BP_UTILIZATION administrative view - Retrieve
hit ratio information” on page 1204 metrics for bufferpools” on page 364
“BP_READ_IO administrative view - Retrieve bufferpool Version 10.5 “MON_BP_UTILIZATION administrative view - Retrieve
read performance information” on page 1206 metrics for bufferpools” on page 364
“BP_WRITE_IO administrative view - Retrieve bufferpool Version 10.5 “MON_BP_UTILIZATION administrative view - Retrieve
write performance information” on page 1208 metrics for bufferpools” on page 364
“CONTAINER_UTILIZATION administrative view - Version 10.5 “MON_GET_CONTAINER table function - Get table space
Retrieve table space container and utilization container metrics” on page 568
information” on page 1210
“LOG_UTILIZATION administrative view - Retrieve log Version 10.5 “MON_TRANSACTION_LOG_UTILIZATION administrative Version 10.5
utilization information” on page 1272 view - Retrieve log utilization information” on page 395
“LONG_RUNNING_SQL administrative view” on page Version 10.5 “MON_CURRENT_SQL - Retrieve key metrics for all
1273 activities on all members” on page 376
“SNAPAPPL administrative view and SNAP_GET_APPL Version 10.5 “MON_GET_CONNECTION table function - Get connection
table function - Retrieve appl logical data group snapshot metrics” on page 532
information” on page 1301
“SNAPAPPL_INFO administrative view and Version 10.5 “MON_GET_CONNECTION table function - Get connection
SNAP_GET_APPL_INFO table function - Retrieve metrics” on page 532
appl_info logical data group snapshot information” on
page 1287
“SNAPBP administrative view and SNAP_GET_BP table Version 10.5 “MON_GET_BUFFERPOOL table function - Get buffer pool
function - Retrieve bufferpool logical group snapshot metrics” on page 513
information” on page 1316
“SNAPBP_PART administrative view and Version 10.5 “MON_GET_BUFFERPOOL table function - Get buffer pool
SNAP_GET_BP_PART table function - Retrieve metrics” on page 513
bufferpool_nodeinfo logical data group snapshot
information” on page 1321
Deprecated Replacement
Deprecated routine or view since New routine or view available since
“SNAPCONTAINER administrative view and Version 10.5 “MON_GET_CONTAINER table function - Get table space
SNAP_GET_CONTAINER table function - Retrieve container metrics” on page 568
tablespace_container logical data group snapshot
information” on page 1329
“SNAPDB administrative view and SNAP_GET_DB table Version 10.5 “MON_GET_DATABASE table function - Get database Version 10.5
function - Retrieve snapshot information from the dbase metrics” on page 571
logical group” on page 1335
“SNAPDBM administrative view and SNAP_GET_DBM Version 10.5 “MON_GET_INSTANCE table function - Get instance level Version 10.5
table function - Retrieve the dbm logical grouping information” on page 622
snapshot information” on page 1363
“SNAPFCM administrative view and SNAP_GET_FCM table Version 10.5 “MON_GET_FCM - Get FCM metrics” on page 607
function - Retrieve the fcm logical data group snapshot
information” on page 1383
“SNAPDETAILLOG administrative view and Version 10.5 “MON_GET_TRANSACTION_LOG table function - Get log Version 10.5
SNAP_GET_DETAILLOG table function - Retrieve information” on page 843
snapshot information from the detail_log logical data
group” on page 1374
“SNAPFCM_PART administrative view and Version 10.5 “MON_GET_FCM - Get FCM metrics” on page 607
SNAP_GET_FCM_PART table function - Retrieve the
fcm_node logical data group snapshot information” on
page 1386
Version 10.5 “MON_CURRENT_SQL - Retrieve key metrics for all Version 9.7
“SNAPSTMT administrative view and SNAP_GET_STMT
activities on all members” on page 376 and
table function - Retrieve statement snapshot information”
“MON_GET_CONNECTION table function - Get connection
on page 1408
metrics” on page 532
“SNAPTBSP administrative view and SNAP_GET_TBSP Version 10.5 “MON_GET_TABLESPACE table function - Get table space
table function - Retrieve table space logical data group metrics” on page 820
snapshot information” on page 1424
“SNAPTBSP_PART administrative view and Version 10.5 “MON_GET_TABLESPACE table function - Get table space
SNAP_GET_TBSP_PART table function - Retrieve metrics” on page 820
tablespace_nodeinfo logical data group snapshot
information” on page 1430
“SNAPTBSP_QUIESCER administrative view and Version 10.5 “MON_GET_TABLESPACE_QUIESCER table function - Get Version 10.5 Fix
SNAP_GET_TBSP_QUIESCER table function - Retrieve information about quiesced table spaces ” on page 833 Pack 3
quiescer table space snapshot information” on page 1443
“SNAPTBSP_RANGE administrative view and Version 10.5 “MON_GET_TABLESPACE_RANGE table function - Get Version 10.5 Fix
SNAP_GET_TBSP_RANGE table function - Retrieve range information about table space ranges ” on page 836 Pack 3
snapshot information” on page 1404
“SNAPUTIL administrative view and SNAP_GET_UTIL Version 10.5 “MON_GET_UTILITY table function - Get utilities running Version 10.5
table function - Retrieve utility_info logical data group on the database” on page 885
snapshot information” on page 1447
“TBSP_UTILIZATION administrative view - Retrieve table Version 10.5 “MON_TBSP_UTILIZATION - Retrieve monitoring metrics
space configuration and utilization information” on page for all table spaces and all database partitions” on page
1592 390
“ADMIN_GET_DBP_MEM_USAGE table function - Get Version 10.1 “ADMIN_GET_MEM_USAGE table function - Get total Version 10.1
total memory consumption for instance” on page 1156 memory consumption for instance” on page 161
“ADMINTABCOMPRESSINFO administrative view and Version 10.1 “ADMIN_GET_TAB_COMPRESS_INFO table function - Version 10.1
ADMIN_GET_TAB_COMPRESS_INFO table function estimate compression savings” on page 174 and
(deprecated) - returns compressed information” on page “ADMIN_GET_TAB_DICTIONARY_INFO table function -
1157 report properties of existing table dictionaries” on page
177
“ADMIN_GET_TAB_INFO_V95 table function - Retrieve Version 10.1 “ADMIN_GET_TAB_INFO table function” on page 181 Version 10.1
size and state information for tables” on page 1169
“ADMIN_GET_TAB_INFO_V97 table function - Retrieve Version 10.1 “ADMIN_GET_TAB_INFO table function” on page 181 Version 10.1
size and state information for tables” on page 1175
Deprecated Replacement
Deprecated routine or view since New routine or view available since
“AM_BASE_RPTS - Activity event monitor reports” on Version 10.1 Not available Version 10.1
page 1183
“AM_DROP_TASK - Delete a monitoring task” on page Version 10.1 Not available Version 10.1
1185
“AM_GET_LOCK_CHN_TB - Retrieve application lock Version 10.1 Not available Version 10.1
chain data in a tabular format” on page 1185
“AM_GET_LOCK_CHNS - Retrieve lock chain information Version 10.1 Not available Version 10.1
for a specific application” on page 1186
“AM_GET_LOCK_RPT - Retrieve application lock details” Version 10.1 Not available Version 10.1
on page 1187
“AM_GET_RPT - Retrieve activity monitor data” on page Version 10.1 Not available Version 10.1
1195
“AM_SAVE_TASK - Create or modify a monitoring task” on Version 10.1 Not available Version 10.1
page 1196
“APPLICATION_ID ” on page 1203 Version 10.1 “MON_GET_APPLICATION_ID - Get connection Version 10.1
application ID” on page 508
“REG_VARIABLES administrative view - Retrieve Version 10.1 “ENV_GET_REG_VARIABLES table function - Retrieve Version 10.1
database registry settings in use” on page 1276 database registry settings that are in use” on page 335
“SNAPAGENT_MEMORY_POOL administrative view and Version 10.1 “MON_GET_MEMORY_POOL - get memory pool Version 10.1
SNAP_GET_AGENT_MEMORY_POOL table function - information” on page 633 and “MON_GET_MEMORY_SET
Retrieve memory_pool logical data group snapshot - get memory set information ” on page 635
information” on page 1282
“SNAP_GET_APPL_INFO_V95 table function - Retrieve Version 10.1 “MON_GET_CONNECTION table function - Get connection Version 10.1
appl_info logical data group snapshot information” on metrics” on page 532
page 1295
“SNAP_GET_APPL_V95 table function - Retrieve appl Version 10.1 “MON_GET_CONNECTION table function - Get connection Version 10.1
logical data group snapshot information” on page 1309 metrics” on page 532
“SNAP_GET_BP_V95 table function - Retrieve bufferpool Version 10.1 “MON_GET_BUFFERPOOL table function - Get buffer pool Version 10.1
logical group snapshot information” on page 1325 metrics” on page 513
“SNAP_GET_CONTAINER_V91 table function - Retrieve Version 10.1 “MON_GET_CONTAINER table function - Get table space Version 10.1
tablespace_container logical data group snapshot container metrics” on page 568
information” on page 1333
“SNAP_GET_DB_V97 table function - Retrieve snapshot Version 10.1 “MON_GET_DATABASE table function - Get database Version 10.1
information from the dbase logical group” on page 1353 metrics” on page 571
“SNAP_GET_DBM_V95 table function - Retrieve the dbm Version 10.1 “MON_GET_INSTANCE table function - Get instance level Version 10.1
logical grouping snapshot information” on page 1371 information” on page 622
“SNAP_GET_DETAILLOG_V91 table function - Retrieve Version 10.1 MON_GET_TRANSACTION_LOG table function Version 10.1
snapshot information from the detail_log logical data
group” on page 1377
“SNAP_GET_DYN_SQL_V95 table function - Retrieve Version 10.1 “SNAP_GET_DYN_SQL table function” on page 976 Version 10.1
dynsql logical group snapshot information” on page 1379
“SNAPSTORAGE_PATHS administrative view and Version 10.1 “ADMIN_GET_STORAGE_PATHS table function - retrieve Version 10.1
SNAP_GET_STORAGE_PATHS_V97 table function - automatic storage path information” on page 164
Retrieve automatic storage path information” on page
1415
Version 10.1 “MON_GET_BUFFERPOOL table function - Get buffer pool Version 10.1
metrics” on page 513, “MON_GET_TABLE table function -
“SNAPTAB administrative view and SNAP_GET_TAB table
get table metrics” on page 814, “MON_GET_TABLESPACE
function - Retrieve table logical data group snapshot
table function - Get table space metrics” on page 820,
information” on page 1419
and “MON_BP_UTILIZATION administrative view -
Retrieve metrics for bufferpools” on page 364
“SNAP_GET_TAB_V91 ” on page 1422 Version 10.1 “MON_GET_TABLE table function - get table metrics” on Version 10.1
page 814
“SNAP_GET_TBSP_PART_V97 table function - Retrieve Version 10.1 “MON_GET_TABLESPACE table function - Get table space Version 10.1
tablespace_nodeinfo logical data group snapshot metrics” on page 820
information” on page 1435
“SNAP_GET_TBSP_V91 ” on page 1439 Version 10.1 “MON_GET_TABLESPACE table function - Get table space Version 10.1
metrics” on page 820
Deprecated Replacement
Deprecated routine or view since New routine or view available since
“SNAPHADR administrative view and SNAP_GET_HADR Version 10.1 “MON_GET_HADR table function - Returns high Version 10.1
table function - Retrieve hadr logical data group snapshot availability disaster recovery (HADR) monitoring
information” on page 1389 information” on page 610
“WLM_GET_SERVICE_CLASS_AGENTS_V97 - List agents Version 10.1 “MON_GET_AGENT table function - List agents, fenced Version 10.1
running in a service class” on page 1601 mode processes, and system entities for the database”
on page 494
“WLM_GET_WORKLOAD_OCCURRENCE_ACTIVITIES_V9 Version 10.1 “MON_GET_ACTIVITY table function - Return a list of Version 10.1
7 - Return a list of activities” on page 1617 activities” on page 454
“WLM_GET_WORKLOAD_STATS_V97 - return workload Version 10.1 “WLM_GET_WORKLOAD_STATS table function - Return Version 10.1
statistics” on page 1620 workload statistics” on page 1100
“DB_PARTITIONS ” on page 1212 Version 9.8 “DB2_MEMBER and DB2_CF administrative views and Version 9.8
DB2_GET_INSTANCE_INFO table function” on page 322
“SNAPDB_MEMORY_POOL administrative view and Version 9.7 “MON_GET_MEMORY_SET - Version 9.7 Fix
SNAP_GET_DB_MEMORY_POOL table function - Retrieve get memory set information ” on page 635 Pack 5
database level memory usage information” on page 1348 “MON_GET_MEMORY_POOL -
get memory pool information” on page 633
“SNAPDBM_MEMORY_POOL administrative view and Version 9.7 “MON_GET_MEMORY_SET - Version 9.7 Fix
SNAP_GET_DBM_MEMORY_POOL table function - get memory set information ” on page 635 Pack 5
Retrieve database manager level memory usage “MON_GET_MEMORY_POOL -
information” on page 1368 get memory pool information” on page 633
“LOCKS_HELD administrative view - Retrieve information Version 9.7 “MON_GET_APPL_LOCKWAIT - Get information about Version 9.7 Fix
about locks held” on page 1265 locks for which an application is waiting” on page 503 Pack 1
“LOCKWAITS administrative view - Retrieve current Version 9.7 “MON_GET_APPL_LOCKWAIT - Get information about Version 9.7 Fix
lockwaits information” on page 1268 locks for which an application is waiting” on page 503 Pack 1
“SNAPLOCK administrative view and SNAP_GET_LOCK Version 9.7 “MON_GET_APPL_LOCKWAIT - Get information about Version 9.7 Fix
table function - Retrieve lock logical data group snapshot locks for which an application is waiting” on page 503 Pack 1
information” on page 1393
“MON_GET_LOCKS - List all locks in the currently
connected database” on page 628
Deprecated Replacement
Deprecated routine or view since New routine or view available since
“SNAPLOCKWAIT administrative view and Version 9.7 “MON_GET_APPL_LOCKWAIT - Get information about Version 9.7 Fix
SNAP_GET_LOCKWAIT table function - Retrieve lockwait locks for which an application is waiting” on page 503 Pack 1
logical data group snapshot information” on page 1398
“MON_GET_LOCKS - List all locks in the currently
connected database” on page 628
“WLM_GET_ACTIVITY_DETAILS - Return detailed Version 9.5 “MON_GET_ACTIVITY_DETAILS table function - Return Version 9.7
information about a specific activity” on page 1595 information about an activity as an XML document” on
page 472
“GET_DB_CONFIG ” on page 1221 Version 9.1 “DBCFG administrative view and DB_GET_CFG table Version 9.1
function - Retrieve database configuration parameter
information” on page 310
“GET_DBM_CONFIG ” on page 1222 Version 9.1 “DBMCFG administrative view and DBM_GET_CFG table Version 9.1
function - Retrieve database manager configuration
parameter information” on page 313
“SNAP_GET_STO_PATHS ” on page 1414 Version 9.1 “ADMIN_GET_STORAGE_PATHS table function - retrieve Version 10.1
automatic storage path information” on page 164
The health monitor has been deprecated. The health monitor routines are also deprecated and might be
removed from future releases. A new suite of GUI tools for managing data and data-centric applications is
available and can be used instead of the discontinued Control Center tools. For more information, see
Database management and application development tools.
The following section is a list of the deprecated health monitor routines:
• “HEALTH_CONT_HI ” on page 1223
• “HEALTH_CONT_HI_HIS ” on page 1225
• “HEALTH_CONT_INFO ” on page 1227
• “HEALTH_DB_HI ” on page 1229
• “HEALTH_DB_HI_HIS ” on page 1232
• “HEALTH_DB_HIC ” on page 1235
• “HEALTH_DB_HIC_HIS ” on page 1237
• “HEALTH_DB_INFO ” on page 1240
• “HEALTH_DBM_HI ” on page 1242
• “HEALTH_DBM_HI_HIS ” on page 1243
• “HEALTH_DBM_INFO ” on page 1245
• “HEALTH_GET_ALERT_ACTION_CFG ” on page 1247
• “HEALTH_GET_ALERT_CFG ” on page 1250
• “HEALTH_GET_IND_DEFINITION ” on page 1253
• “HEALTH_HI_REC ” on page 1255
• “HEALTH_TBS_HI ” on page 1257
• “HEALTH_TBS_HI_HIS ” on page 1259
• “HEALTH_TBS_INFO ” on page 1263
Syntax
ADMIN_GET_DBP_MEM_USAGE ( )
member
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Information returned
Examples
Example 1: Retrieve memory usage statistics from database partition 3
1 record(s) selected.
Example 2: Retrieve memory usage statistics from the currently connected member (assuming the user is
connected to the database at member 2.)
1 record(s) selected.
4 record(s) selected.
3 record(s) selected.
Authorization
One of the following authorizations is required:
• SELECT privilege on the ADMINTABCOMPRESSINFO administrative view
• CONTROL privilege on the ADMINTABCOMPRESSINFO administrative view
• DATAACCESS authority
In addition, one of the following privileges or authorities is also required:
• EXECUTE privilege on the ADMIN_GET_TAB_COMPRESS_INFO table function
• DATAACCESS authority
Examples
Example 1: Retrieve all compression information for all tables
Example 2: Determine the dictionary building action and time of dictionary creation for all tables.
Syntax
ADMIN_GET_TAB_COMPRESS_INFO ( tabschema , tabname , execmode
Authorization
EXECUTE privilege on the ADMIN_GET_TAB_COMPRESS_INFO function.
Examples
Example 1: Retrieve existing compression information for table SIMAP2.STAFF
1 record(s) selected.
1 record(s) selected.
28 record(s) selected.
Example 4: View a report of the dictionary information of tables in the SIMAP2 schema.
4 record(s) selected.
Usage notes
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is empty (") or NULL, information is returned for all tables in
the given schema.
• 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.
Information returned
DICT_BUILDER VARCHAR(30) Code path taken to build the dictionary which can be one
of the following values:
• 'INSPECT' = INSPECT ROWCOMPESTIMATE
• 'LOAD' = LOAD INSERT/REPLACE
• 'NOT BUILT' = no dictionary available
• 'REDISTRIBUTE' = REDISTRIBUTE
• 'REORG' = REORG RESETDICTIONARY
• 'TABLE GROWTH' = INSERT
• 'TABLE FUNCTION' = built by table function for the
'ESTIMATE' option
ADMIN_GET_TAB_COMPRESS_INFO
_V97
The ADMIN_GET_TAB_COMPRESS_INFO_V97 table function returns compression information for tables,
materialized query tables (MQT) and hierarchy tables.
Note: This table function has been deprecated and replaced by the ADMIN_GET_TAB_COMPRESS_INFO
table function and the ADMIN_GET_TAB_DICTIONARY_INFO table function.
Refer to the Table 230 on page 1167 table for a complete list of information that can be returned.
Syntax
ADMIN_GET_TAB_COMPRESS_INFO_V97 ( tabschema , tabname ,
execmode )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
Examples
Example 1: Retrieve existing compression information for table SIMAP2.STAFF
SELECT *
FROM TABLE (
SYSPROC.ADMIN_GET_TAB_COMPRESS_INFO_V97('SIMAP2', 'STAFF', 'REPORT'))
AS T
2 record(s) selected.
SELECT *
FROM TABLE (
SYSPROC.ADMIN_GET_TAB_COMPRESS_INFO_V97('SIMAP2', 'STAFF', 'ESTIMATE'))
AS T
2 record(s) selected.
44 record(s) selected.
Example 4: View a report of the dictionary information of tables in the SIMAP2 schema.
44 record(s) selected.
Example 5: View a report of the dictionary information of DATA objects of tables in the SIMAP2 schema.
22 record(s) selected.
70 70 31 DATA
0 0 0 DATA
Example 6: View a report of the dictionary information of XML objects of the CUSTOMER table in the
SIMAP2 schema.
Usage notes
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is empty (") or NULL, information is returned for all tables in
the given schema.
• 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.
• If both tabschema and tabname are empty (") or NULL, information is returned for all tables.
• 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.
• When the ADMIN_GET_TAB_COMPRESS_INFO_V97 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.
• If the queried table is a non-XML table, there will be a row returned for the XML storage object (XDA).
Information returned
DICT_BUILDER VARCHAR(30) Code path taken to build the dictionary which can be one
of the following values:
• 'INSPECT' = INSPECT ROWCOMPESTIMATE
• 'LOAD' = LOAD INSERT/REPLACE
• 'NOT BUILT' = no dictionary available
• 'REDISTRIBUTE' = REDISTRIBUTE
• 'REORG' = REORG RESETDICTIONARY
• 'TABLE GROWTH' = INSERT
• 'TABLE FUNCTION' = built by table function for the
'ESTIMATE' option
Syntax
ADMIN_GET_TAB_INFO_V95 ( tabschema , tabname )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve size and state information for the table DBUSER1.EMPLOYEE.
Example 2: Suppose there exists a non-partitioned table (DBUSER1.EMPLOYEE), with all associated
objects (for example, indexes and LOBs) stored in a single table space. Calculate how much physical
space the table is using in the table space:
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:
1 record(s) selected.
Usage notes
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is empty (") or NULL, information is returned for all tables in
the given schema.
• 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.
• If both tabschema and tabname are empty (") or NULL, information is returned for all tables.
• 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.
• 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). The lock
will only be held for as long as it takes to retrieve the size and state information for the table, not for the
duration of the table function call.
• Physical size reported for tables in SMS table spaces is the same as logical size.
• When an inplace reorg is active on a table, the physical size for the data object (DATA_OBJECT_P_SIZE)
will not be calculated. Only the logical size will be returned. You can tell if an inplace reorg is active on
the table by looking at the INPLACE_REORG_STATUS output column.
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
Information returned
DATA_OBJECT_L_SIZE BIGINT Data object logical size. Amount of disk space logically
allocated for the table, reported in kilobytes. The logical
size is the amount of space that the table knows about.
It might be less than the amount of space physically
allocated for the table (for example, in the case of a
logical table truncation). For multi-dimensional
clustering (MDC) tables, this size includes the logical
size of the block map object. The size returned takes
into account full extents that are logically allocated for
the table and, for objects created in DMS table spaces,
an estimate of the Extent Map Page (EMP) extents. This
size represents the logical size of the base table only.
Space consumed by LOB data, Long Data, Indexes and
XML objects are reported by other columns.
DATA_OBJECT_P_SIZE BIGINT Data object physical size. Amount of disk space
physically allocated for the table, reported in kilobytes.
For MDC tables, this size includes the size of the block
map object. The size returned takes into account full
extents allocated for the table and includes the EMP
extents for objects created in DMS table spaces. This
size represents the physical size of the base table only.
Space consumed by LOB data, Long Data, Indexes and
XML objects are reported by other columns.
INDEX_OBJECT_L_SIZE BIGINT Index object logical size. Amount of disk space logically
allocated for the indexes defined on the table, reported
in kilobytes. The logical size is the amount of space that
the table knows about. It might be less than the amount
of space physically allocated to hold index data for the
table (for example, in the case of a logical table
truncation). The size returned takes into account full
extents that are logically allocated for the indexes and,
for indexes created in DMS table spaces, an estimate of
the EMP extents. This value is only reported for non-
partitioned tables. For partitioned tables, this value will
be 0.
LOAD_STATUS VARCHAR(12) Current status of a load operation against the table. The
status value can be one of the following values:
• IN_PROGRESS
• NULL (if there is no load in progress for the table and
the table is not in load pending state)
• PENDING
READ_ACCESS_ONLY CHAR(1) 'Y' if the table is in Read Access Only state, 'N'
otherwise. A value of 'N' should not be interpreted as
meaning that the table is fully accessible. If a load is in
progress or pending, a value of 'Y' means the table data
is available for read access, and a value of 'N' means the
table is inaccessible. Similarly, if the table status is set
integrity pending (refer to SYSCAT.TABLES STATUS
column), then a value of 'N' means the table is
inaccessible.
NO_LOAD_RESTART CHAR(1) A value of 'Y' indicates the table is in a partially loaded
state that will not allow a load restart. A value of 'N' is
returned otherwise.
NUM_REORG_REC_ALTERS SMALLINT Number of reorg recommend alter operations (for
example, alter operations after which a reorganization is
required) that have been performed against this table
since the last reorganization.
INDEXES_REQUIRE_REBUILD CHAR(1) 'Y' if any of the indexes defined on the table require a
rebuild, and 'N' otherwise.
Syntax
ADMIN_GET_TAB_INFO_V97 ( tabschema , tabname )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve size and state information for the table DBUSER1.EMPLOYEE.
Example 2: Suppose there exists a non-partitioned table (DBUSER1.EMPLOYEE), with all associated
objects (for example, indexes and LOBs) stored in a single table space. Calculate how much physical
space the table is using in the table space:
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:
Example 4: Determine the amount of space reclaimable from a multidimensional clustering table
SAMPLE.STAFF:
SELECT RECLAIMABLE_SPACE
FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO_V97('SAMPLE','STAFF'))
Usage notes
• If both the tabschema and tabname are specified, information is returned for that specific table only.
• If the tabschema is specified but tabname is NULL or the empty string ("), then information is returned
for all tables in the given schema.
• If the tabschema is NULL or the empty string (") and tabname is specified, then an error is returned. To
retrieve information for a specific table, the table must be identified by both schema and table name.
• If both tabschema and tabname are NULL or the empty string ("), then information is returned for all
tables.
• 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.
• When the ADMIN_GET_TAB_INFO_V97 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). The lock
will only be held for as long as it takes to retrieve the size and state information for the table, not for the
duration of the table function call.
• Physical size reported for tables in SMS table spaces is the same as logical size.
• When an inplace reorg is active on a table, the physical size for the data object (DATA_OBJECT_P_SIZE)
will not be calculated. Only the logical size will be returned. You can tell if an inplace reorg is active on
the table by looking at the INPLACE_REORG_STATUS output column.
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
Information returned
Table 232. Information returned by ADMINTABINFO administrative view and the ADMIN_GET_TAB_INFO_V97
Column name Data type Description
TABSCHEMA VARCHAR(128) table_schema - Table schema name monitor element
TABNAME VARCHAR(128) table_name - Table name monitor element
TABTYPE CHAR(1) Table type:
• 'H' = hierarchy table
• 'S' = materialized query table
• 'T' = table
DATA_OBJECT_L_SIZE BIGINT Data object logical size. Amount of disk space logically
allocated for the table, reported in kilobytes. The logical
size is the amount of space that the table knows about.
It might be less than the amount of space physically
allocated for the table (for example, in the case of a
logical table truncation). For multi-dimensional
clustering (MDC) tables, this size includes the logical
size of the block map object. The size returned takes
into account full extents that are logically allocated for
the table and, for objects created in DMS table spaces,
an estimate of the Extent Map Page (EMP) extents. This
size represents the logical size of the base table only.
Space consumed by LOB data, Long Data, Indexes and
XML objects are reported by other columns.
DATA_OBJECT_P_SIZE BIGINT Data object physical size. Amount of disk space
physically allocated for the table, reported in kilobytes.
For MDC tables, this size includes the size of the block
map object. The size returned takes into account full
extents allocated for the table and includes the EMP
extents for objects created in DMS table spaces. This
size represents the physical size of the base table only.
Space consumed by LOB data, Long Data, Indexes and
XML objects are reported by other columns.
LONG_OBJECT_L_SIZE BIGINT Long object logical size. Amount of disk space logically
allocated for long field data in a table, reported in
kilobytes. The logical size is the amount of space that
the table knows about. It might be less than the amount
of space physically allocated to hold long field data for
the table (for example, in the case of a logical table
truncation). The size returned takes into account full
extents that are logically allocated for long field data
and, for long field data created in DMS table spaces, an
estimate of the EMP extents.
LONG_OBJECT_P_SIZE BIGINT Long object physical size. Amount of disk space
physically allocated for long field data in a table,
reported in kilobytes. The size returned takes into
account full extents allocated for long field data and
includes the EMP extents for long field data created in
DMS table spaces.
LOAD_STATUS VARCHAR(12) Current status of a load operation against the table. The
status value can be one of the following values:
• IN_PROGRESS
• NULL (if there is no load in progress for the table and
the table is not in load pending state)
• PENDING
READ_ACCESS_ONLY CHAR(1) 'Y' if the table is in Read Access Only state, 'N'
otherwise. A value of 'N' should not be interpreted as
meaning that the table is fully accessible. If a load is in
progress or pending, a value of 'Y' means the table data
is available for read access, and a value of 'N' means the
table is inaccessible. Similarly, if the table status is set
integrity pending (refer to SYSCAT.TABLES STATUS
column), then a value of 'N' means the table is
inaccessible.
NO_LOAD_RESTART CHAR(1) A value of 'Y' indicates the table is in a partially loaded
state that will not allow a load restart. A value of 'N' is
returned otherwise.
NUM_REORG_REC_ALTERS SMALLINT Number of reorg recommend alter operations (for
example, alter operations after which a reorganization is
required) that have been performed against this table
since the last reorganization.
INDEXES_REQUIRE_REBUILD CHAR(1) For nonpartitioned tables, 'Y' if any of the indexes
defined on the table require a rebuild, and 'N' otherwise.
For partitioned tables, 'Y' if any index partitions for the
data partition identified by DATA_PARTITION_ID
require a rebuild, and 'N' otherwise.
LARGE_RIDS CHAR(1) Indicates whether or not the table is using large row IDs
(RIDs) (4 byte page number, 2 byte slot number). A
value of 'Y' indicates that the table is using large RIDs
and 'N' indicates that it is not using large RIDs. A value
of 'P' (pending) will be returned if the table supports
large RIDs (that is, the table is in a large table space),
but at least one of the indexes for the table has not been
reorganized or rebuilt yet, so the table is still using 4
byte RIDs (which means that action must be taken to
convert the table or indexes).
XML_RECORD_TYPE SMALLINT Indicates the type of XML record currently in use for the
table.
• 1 if the type-1 (single node) XML record format is
being used.
• 2 if the type-2 (multi-node) XML record format is
being used.
• Null if the table has no XML columns.
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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 event 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
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1:
Example 2:
Information returned
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
AM_DROP_TASK ( task_id )
Procedure parameter
task_id
An input argument of type INTEGER that specifies a unique monitoring task ID.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Drop the monitoring task with ID 5.
CALL SYSPROC.AM_DROP_TASK(5)
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
AM_GET_LOCK_CHN_TB ( agent_id )
Authorization
• SYSMON authority
• EXECUTE privilege on the AM_GET_LOCK_CHN_TB procedure.
Example
Retrieve lock chain information for agent ID 68.
CALL SYSPROC.AM_GET_LOCK_CHN_TB(68)
Information returned
The procedure returns the following table. Each row of this 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.
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
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
• SYSMON authority
• EXECUTE privilege on the AM_GET_LOCK_CHNS procedure.
Example
CALL SYSPROC.AM_GET_LOCK_CHNS(17,?)
Return Status = 0
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
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
• SYSMON authority
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.
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
Procedure parameters
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
PRIMARY_AUTH_ID, where AGENT_ID and PRIMARY_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 applications, statements,
or transactions that are to be displayed. If the argument is null, all applications, statements, and
transactions will be displayed.
Example
Usage note
The result set returned is different for each report id. This procedure is intended to support the
discontinued Activity Monitor graphical tool. To build reports that can be parsed, snapshot administrative
SQL routines and views should be used instead. To use this procedure, the DFT_MON_LOCK monitor
switch must be turned on.
Syntax
Important: The related activity monitor routines is deprecated and might be removed in a future release.
For more information, see "Activity monitor routines have been deprecated" at http://www.ibm.com/
support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.wn.doc/doc/i0059660.html.
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
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Example:
Authorization
One of the following authorizations is required:
• SELECT privilege on the APPL_PERFORMANCE administrative view
• CONTROL privilege on the APPL_PERFORMANCE administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
Example
Retrieve the report on application performance.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the APPLICATIONS administrative view
• CONTROL privilege on the APPLICATIONS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Example 1: List information for all the active applications in the single-partitioned database SAMPLE.
1 record(s) selected.
Example 2: List the number of agents per application on database partition 0 for the multi-partition
database SAMPLE.
APPL_NAME NUM
---------- -----------
db2bp.exe 3
javaw.exe 1
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
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.
Note: This scalar function has been deprecated and replaced by the MON_GET_APPLICATION_ID scalar
function.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Authorization
One of the following authorizations is required:
• SELECT privilege on the BP_HITRATIO administrative view
• CONTROL privilege on the BP_HITRATIO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a report for all bufferpools in the connected database.
Usage notes
The ratio of physical reads to total 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
Authorization
One of the following authorizations is required:
• SELECT privilege on the BP_READ_IO administrative view
• CONTROL privilege on the BP_READ_IO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve total physical reads and average read time for all bufferpools on all partitions of the currently
connected database.
10 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the BP_WRITE_IO administrative view
• CONTROL privilege on the BP_WRITE_IO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
Example
Retrieve total writes and average write time for all bufferpools on all database partitions of the currently
connected database.
11 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the CONTAINER_UTILIZATION administrative view
• CONTROL privilege on the CONTAINER_UTILIZATION administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
5 record(s) selected.
Information returned
The BUFFERPOOL snapshot monitor switch must be enabled at the database manager configuration for
the file system information to be returned.
DB_PARTITIONS
The DB_PARTITIONS table function returns the contents of the db2nodes.cfg file in table format.
Note: This table function has been deprecated and replaced by the DB2_MEMBER and DB2_CF
administrative views and DB2_GET_INSTANCE_INFO table function.
Syntax
DB_PARTITIONS ( )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
4 record(s) selected.
In a Db2 pureScale environment, retrieve information from a 3 member and 1 cluster caching facility Db2
pureScale instance.
3 record(s) selected.
Usage notes
For Db2 Enterprise Server Edition and in a partitioned database environment, the DB_PARTITIONS table
function returns one row for each entry in the db2nodes.cfg file.
In a Db2 pureScale environment, the DB_PARTITIONS table function returns multiple rows, with the
following information in the columns:
• The PARTITION_NUMBER column always contains 0.
• The remaining columns show information for the entry in the db2nodes.cfg file for the current
member.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the ENV_SYS_RESOURCES administrative view
• CONTROL privilege on the ENV_SYS_RESOURCES administrative view
• DATAACCESS authority
Example
4 record(s) selected.
Usage Notes
To return accurate results, the ENV_SYS_RESOURCES administrative view takes more than 1 second on
AIX, HP, and Windows operating systems.
Syntax
ENV_GET_SYS_RESOURCES ( )
Authorization
EXECUTE privilege on the ENV_GET_SYS_RESOURCES table function.
22 record(s) selected.
Usage Notes
To return accurate results, the ENV_GET_SYS_RESOURCES table function takes more than 1 second on
AIX, HP, and Windows operating systems.
GET_DB_CONFIG
The GET_DB_CONFIG procedure returns database configuration information. The procedure does not
take any arguments.
Note: This procedure has been deprecated and replaced by the “DBCFG administrative view and
DB_GET_CFG table function - Retrieve database configuration parameter information” on page 310.
GET_DB_CONFIG ( )
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.
Authorization
One of the following authorities is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Using the command line processor (CLP), change the value of the logarchmeth1 database configuration
parameter. 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
DBCONFIG_TYPE LOGARCHMETH1
------------- ------------
0 1
1 0
2 record(s) selected.
GET_DBM_CONFIG
The GET_DBM_CONFIG table function returns database manager configuration information. The function
does not take any arguments.
Note: This table function has been deprecated and replaced by the “DBMCFG administrative view and
DBM_GET_CFG table function - Retrieve database manager configuration parameter information” on page
313.
GET_DBM_CONFIG ( )
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
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.
CONNECT TO SAMPLE
CONNECT RESET
2 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.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_CONT_HI ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
5 record(s) selected.
Information returned
HEALTH_CONT_HI_HIS
Returns health indicator history information for containers from a health snapshot of a database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_CONT_HI_HIS ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
Example
10 record(s) selected.
HEALTH_CONT_INFO
The HEALTH_CONT_INFO table function returns container information from a health snapshot of a
database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_CONT_INFO ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
5 record(s) selected.
Information returned
HEALTH_DB_HI
The HEALTH_DB_HI table function returns health indicator information from a health snapshot of a
database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_DB_HI ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
11 record(s) selected.
... HI_ADDITIONAL_INFO
... ----------------------------------------
... -
... The high watermark for shared sort
... memory is "57". "99"% of the time
... the sort heap allocation is less
... than or equal to "246". The sort
... heap (sortheap) database
... configuration parameter is set
... to "256". The high watermark for
... private sort memory is "0".
... The sort heap (sortheap) database
... configuration parameter is set to
... "256". The high watermark for
... private sort memory is "57". The
... high watermark for shared sort
... memory is "0"
... The following are the related
... database configuration parameter
... settings: logprimary is "3",
... logsecond is "2", and logfilsiz
... is "1000". The application with
... the oldest transaction is "712".
... The following are the related
... database configuration parameter
... settings: logprimary is "3",
... logsecond is "2", and logfilsiz
... is "1000", blk_log_dsk_ful is
... "NO", logarchmeth1 is "OFF" and
... logarchmeth2 is "OFF".
... -
... -
... -
... The scope setting in the reorganization
... policy is "TABSCHEMA NOT LIKE 'SYS%'".
... Automatic reorganization (AUTO_REORG)
... for this database is set to "OFF".
... The longest estimated reorganization
... time is "N/A".
... The last successful backup was taken
... at "N/A". The log space consumed since
... this last backup has been "N/A" 4KB
... pages. Automation for database backup
... is set to "OFF". The last automated
... backup returned with SQLCODE = "N/A".
... The longest estimated backup time
... is "N/A".
... The scope is "N\A". Automatic
... statistics collection (AUTO_RUNSTATS)
... is set to "OFF".
HEALTH_DB_HI_HIS
The HEALTH_DB_HI_HIS table function returns health indicator history information from a health
snapshot of a database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_DB_HI_HIS ( dbname , member )
Example
... HI_ADDITIONAL_INFO
... ---------------------------------------
... -
...
... The high watermark for shared sort
... memory is "15". "99"% of the time
... the sort heap allocation is less
... than or equal to "246". The sort
... heap (sortheap) database
... configuration parameter is set
... to "256". The high watermark
... for private sort memory is "0".
...
... The sort heap (sortheap) database
... configuration parameter is set
... to "256". The high watermark for
... private sort memory is "15". The
... high watermark for shared sort
... memory is "0"
...
... The following are the related
... database configuration parameter
... settings: logprimary is "3",
... logsecond is "2", and logfilsiz
Information returned
HEALTH_DB_HIC
The HEALTH_DB_HIC function returns collection health indicator information from a health snapshot of a
database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
Syntax
HEALTH_DB_HIC ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
2 record(s) selected.
Information returned
HEALTH_DB_HIC_HIS
Returns collection health indicator history information from a health snapshot of a database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
Syntax
HEALTH_DB_HIC_HIS ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
10 record(s) selected.
Information returned
HEALTH_DB_INFO
The HEALTH_DB_INFO table function returns information from a health snapshot of a database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_DB_INFO ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
1 record(s) selected.
Information returned
HEALTH_DBM_HI
The HEALTH_DBM_HI table function returns health indicator information from a health snapshot of the
database manager.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_DBM_HI ( member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
HEALTH_DBM_HI_HIS
The HEALTH_DBM_HI_HIS table function returns health indicator history information from a health
snapshot of the database manager.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_DBM_HI_HIS ( member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
18 record(s) selected.
Information returned
HEALTH_DBM_INFO
The HEALTH_DBM_INFO function returns information from a health snapshot of the database manager.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
Syntax
HEALTH_DBM_INFO ( member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
1 record(s) selected.
HEALTH_GET_ALERT_ACTION_CFG
Returns health alert action configuration settings for various object types (database manager, database,
table space, and table space container) and for various configuration levels (install default, instance,
global, and object).
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_GET_ALERT_ACTION_CFG ( objecttype , cfg_level , dbname ,
objectname )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve object level alert action configuration settings for database SAMPLE for health
indicator 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.
2 record(s) selected.
Usage notes
The HEALTH_GET_IND_DEFINITION table function can be used to map health indicator IDs to the health
indicator names.
Information returned
HEALTH_GET_ALERT_CFG
Returns health alert configuration settings for various object types (database manager, database, table
space, table space container) and for various configuration levels (install default, global, and object).
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_GET_ALERT_CFG ( objecttype , cfg_level , dbname ,
objectname )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Examples
Example 1: Retrieve the object level alert configuration settings for database SAMPLE.
Example 2: Retrieve the warning and alarm thresholds for the health indicator ID '2002' for table space
USERSPACE1 in database SAMPLE.
WARNING_THRESHOLD ALARM_THRESHOLD
-------------------- --------------------
80 90
SQL22004N Cannot find the requested configuration for the given object.
Returning default configuration for "tablespaces".
Usage notes
The HEALTH_GET_IND_DEFINITION table function can be used to map health indicator IDs to the health
indicator names.
Example: Retrieve the warning and alarm thresholds for the health indicator Tablespace Utilization
(ts.ts_util) for table space USERSPACE1 in database SAMPLE.
WARNING_THRESHOLD ALARM_THRESHOLD
-------------------- --------------------
80 90
SQL22004N Cannot find the requested configuration for the given object.
Returning default configuration for "tablespaces".
HEALTH_GET_IND_DEFINITION
Returns the health indicator definitions.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_GET_IND_DEFINITION ( locale )
Examples
Example 1: Retrieve the type and short description for health indicator db.db_op_status in French.
TYPE SHORT_DESCRIPTION
---------------- ----------------------------------------...---------
STATE Etat opérationnel de la base de données
1 record(s) selected.
Example 2: Retrieve the short description for health indicator ID 1001 in English.
SHORT_DESCRIPTION
-----------------------------...-------------
Database Operational State
ID NAME
-------------------- ----------------------------
1 db2.db2_op_status
2 db2.sort_privmem_util
4 db2.mon_heap_util
1001 db.db_op_status
1002 db.sort_shrmem_util
...
2001 ts.ts_op_status
2002 ts.ts_util
...
3002 tsc.tscont_util
1015 db.tb_reorg_req
...
HEALTH_HI_REC
Retrieves a set of recommendations that address a health indicator in alert state on a particular database
object. Recommendations are returned in an XML document that contains information about actions that
can be taken (for example, scripts that can be run) to resolve the alert state.
Important: This procedure has been deprecated and might be removed in a future release because the
health monitor was deprecated in Version 9.7.
Syntax
recommendation-doc )
Procedure parameters
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 Health Recommendation schema definition (see the XML schema
DB2RecommendationSchema.xsd, located in the misc subdirectory of the sqllib directory). The
XML document is encoded in UTF-8, and text in the document is in the locale of the caller, or English,
if messages are not available in the caller's locale at the target instance.
Authorization
One of the following authorities is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
HEALTH_TBS_HI
Returns health indicator information for table spaces from a health snapshot of table spaces in a
database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_TBS_HI ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
11 record(s) selected.
Information returned
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.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_TBS_HI_HIS ( dbname , member )
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
22 record(s) selected.
HEALTH_TBS_INFO
Returns table space information from a health snapshot of a database.
Important: This table function has been deprecated and might be removed in a future release because
the health monitor has been deprecated. It is not supported in Db2 pureScale environments. For more
information, see "Health monitor has been deprecated" at http://www.ibm.com/support/
knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.wn.doc/doc/i0055045.html.
Syntax
HEALTH_TBS_INFO ( dbname , member )
Example
5 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the LOCKS_HELD administrative view
• CONTROL privilege on the LOCKS_HELD administrative view
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Example 1: List the total number of locks held by each table in the database SAMPLE.
Example 2: List all the locks that have not escalated in the currently connected database, SAMPLE.
Example 3: List lock information for the locks that are currently held by the application with agent ID 310.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the LOCKWAITS administrative view
• CONTROL privilege on the LOCKWAITS administrative view
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
Examples
Example 1: List information for all the lock waits for application with 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.
3 record(s) selected.
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the LOG_UTILIZATION administrative view
• CONTROL privilege on the LOG_UTILIZATION administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
List the log utilization for the currently connected database, SAMPLE.
Usage note
For databases that are configured for infinite logging, the LOG_UTILIZATION_PERCENT and
TOTAL_LOG_AVAILABLE_KB will be NULL.
Authorization
One of the following authorizations is required:
• SELECT privilege on the LONG_RUNNING_SQL administrative view
• CONTROL privilege on the LONG_RUNNING_SQL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
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 database
server is not doing anything but rather is waiting for the application to do something (like issue the next
fetch or submit the next SQL statement).
Information returned
Authorization
One of the following authorizations is required:
• SELECT privilege on the REG_VARIABLES administrative view
• CONTROL privilege on the REG_VARIABLES administrative view
• DATAACCESS authority
Example
Request the database registry settings that are currently being used.
6 record(s)
selected.
Information returned
Syntax
REG_LIST_VARIABLES ( )
Authorization
EXECUTE privilege on the REG_LIST_VARIABLES table function.
Usage notes
The output from the db2set command and REG_LIST_VARIABLES might not be identical if a Db2 registry
variable is configured using the db2set command after the instance is started because
REG_LIST_VARIABLES only returns the values that are used when the instance starts.
Example
Request the Db2 registry settings that are currently being used by the current database partition. To
format the output into a manageable table, you can use the SUBSTR scalar function to remove trailing
blanks from variable length character string column values.
SELECT DBPARTITIONNUM,
SUBSTR(REG_VAR_NAME, 1, 15) AS REG_VAR_NAME,
SUBSTR(REG_VAR_VALUE, 1, 13) AS REG_VAR_VALUE,
IS_AGGREGATE,
SUBSTR(AGGREGATE_NAME, 1, 14) AS AGGREGATE_NAME,
LEVEL
FROM TABLE(SYSPROC.REG_LIST_VARIABLES()) AS REGISTRYINFO
6 record(s) selected.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPAGENT administrative view
• CONTROL privilege on the SNAPAGENT administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_AGENT table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
Example
Retrieve all application snapshot information for the currently connected database from the agent logical
data group.
Syntax
SNAP_GET_AGENT ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_AGENT table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve all application snapshot information for all applications in all active databases.
6 record(s) selected.
Information returned
Table 275. Information returned by the SNAPAGENT administrative view and the SNAP_GET_AGENT table
function
Column name Data type Description or corresponding 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 dbpartitionnum - Database partition
number monitor element
MEMBER SMALLINT member - Database member monitor
element
Example
Retrieve a list of memory pools and their current size.
9 record(s) selected.
Syntax
SNAP_GET_AGENT_MEMORY_POOL ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_AGENT_MEMORY_POOL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of memory pools and their current size for all databases.
18 record(s) selected.
Information returned
Table 276. Information returned by the SNAPAGENT_MEMORY_POOL administrative view and the
SNAP_GET_AGENT_MEMORY_POOL table function
Column name Data type Description or corresponding 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)
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPAPPL_INFO administrative view
• CONTROL privilege on the SNAPAPPL_INFO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_APPL_INFO table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Also, one of the following authorities is required:
• SYSMON
• SYSMAINT
• SYSCTRL
• SYSADM
Example
Retrieve the status of the applications connected to the current database.
2 record(s) selected.
Syntax
SNAP_GET_APPL_INFO ( dbname )
, member
Examples
Retrieve the status of all applications on the connected database member.
4 record(s) selected.
The following shows what you obtain when you SELECT from the result of the table function.
DB_NAME AUTHORITY_LVL
-------- -----------------------------------------------------....
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
3 record(s) selected.
Table 277. Information returned by the SNAPAPPL_INFO administrative view and the
SNAP_GET_APPL_INFO table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
AGENT_ID BIGINT agent_id - Application handle (agent ID)
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:
• BACKUP
• COMMIT_ACT
• COMP
• CONNECTED
• CONNECTPEND
• CREATE_DB
• DECOUPLED
• DISCONNECTPEND
• INTR
• IOERROR_WAIT
• LOAD
• LOCKWAIT
• QUIESCE_TABLESPACE
• RECOMP
• REMOTE_RQST
• RESTART
• RESTORE
• ROLLBACK_ACT
• ROLLBACK_TO_SAVEPOINT
• TEND
• THABRT
• THCOMT
• TPREP
• UNLOAD
• UOWEXEC
• UOWWAIT
• WAITFOR_REMOTE
Syntax
SNAP_GET_APPL_INFO_V95 ( dbname )
, member
Examples
Retrieve the status of all applications on the connected database member.
4 record(s) selected.
The following shows what you obtain when you SELECT from the result of the table function.
DB_NAME AUTHORITY_LVL
-------- -----------------------------------------------------....
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
3 record(s) selected.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPAPPL administrative view
• CONTROL privilege on the SNAPAPPL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following privileges or authorities is required to use the table function:
• EXECUTE privilege on the SNAP_GET_APPL table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
Example
Retrieve details on rows read and written for each application in the connected database.
1 record(s) selected.
Syntax
SNAP_GET_APPL ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_APPL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve details on rows read and written for each application for all active databases.
Information returned
Table 279. Information returned by the SNAPAPPL administrative view and the SNAP_GET_APPL table
function
Column name Data type Description or corresponding 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
Syntax
SNAP_GET_APPL_V95 ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_APPL_V95 table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve details on rows read and written for each application for all active databases.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPBP administrative view
• CONTROL privilege on the SNAPBP administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_BP table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve data and index writes for all the bufferpools of the currently connected database.
5 record(s) selected
Syntax
SNAP_GET_BP ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_BP table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve total physical and logical reads for all bufferpools for all active databases for the currently
connected database member.
3 record(s) selected.
Information returned
Table 281. Information returned by the SNAPBP administrative view and the SNAP_GET_BP table function
Column name Data type Description or corresponding 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
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPBP_PART administrative view
• CONTROL privilege on the SNAPBP_PART administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_BP_PART table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve data for all bufferpools when connected to SAMPLE database.
Syntax
SNAP_GET_BP_PART ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_BP_PART table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
Example
Retrieve data for all bufferpools for all active databases when connected to the SAMPLE database.
...
...
Information returned
Table 282. Information returned by the SNAPBP_PART administrative view and the SNAP_GET_BP_PART
table function
Column name Data type Description or corresponding 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
Syntax
SNAP_GET_BP_V95 ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_BP_V95 table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve total physical and logical reads for all bufferpools for all active databases for the currently
connected database member.
3 record(s) selected.
Information returned
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPCONTAINER administrative view
• CONTROL privilege on the SNAPCONTAINER administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_CONTAINER table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Syntax
SNAP_GET_CONTAINER ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_CONTAINER table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve details for the table space containers on the currently connected database on the currently
connected database member.
Information returned
NOTE: The BUFFERPOOL database manager monitor switch must be turned on in order for the file system
information to be returned.
Table 284. Information returned by the SNAPCONTAINER administrative view and the
SNAP_GET_CONTAINER table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
TBSP_NAME VARCHAR(128) tablespace_name - Table space name
TBSP_ID BIGINT tablespace_id - Table space
identification
CONTAINER_NAME VARCHAR(256) container_name - Container name
CONTAINER_ID BIGINT container_id - Container identification
CONTAINER_TYPE VARCHAR(16) container_type - Container type. This is
a text identifier based on the defines in
sqlutil.h and is one of:
• DISK_EXTENT_TAG
• DISK_PAGE_TAG
• FILE_EXTENT_TAG
• FILE_PAGE_TAG
• PATH
Syntax
SNAP_GET_CONTAINER_V91 ( dbname )
, dbpartitionnum
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_CONTAINER_V91 table function
• DATAACCESS authority
Example
Retrieve details for the table space containers on the currently connected database on the currently
connected database partition.
Information returned
NOTE: The bufferpool database manager monitor switch must be turned on in order for the file system
information to be returned.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPDB administrative view
• CONTROL privilege on the SNAPDB administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_DB table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Retrieve the status, platform, location, and connect time for all database members of the currently
connected database.
This routine can be used by calling the following on the command line:
1 record(s) selected.
1 record(s) selected.
Syntax
SNAP_GET_DB ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DB table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Example 1: Retrieve the status, platform, location, and connect time as an aggregate view across all
database members of the currently connected database.
1 record(s) selected.
Example 2: Retrieve the status, platform, location, and connect time as an aggregate view across all
database members for all active databases in the same instance that contains the currently connected
database.
Example 3: This routine can be used by calling the following on the command line:
When connected to a database:
1 record(s) selected.
Example 4: After running a workload, a user can use the following query with the table function.
Continued
...STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
...-------------------- ------------------
... 2 32
1 record(s) selected.
Example 5: The following example shows how you can use the SNAP_GET_DB table function to determine
the status of a database:
SELECT SUBSTR
(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS
FROM table(SNAP_GET_DB('hadrdb', 0))
DB_NAME DB_STATUS
-------------------- ----------------
HADRDB ACTIVE_STANDBY
Information returned
Table 286. Information returned by the SNAPDB administrative view and SNAP_GET_DB table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
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
Authorization
One of the following authorizations is required:
• SELECT privilege on the SNAPDB_MEMORY_POOL administrative view
• CONTROL privilege on the SNAPDB_MEMORY_POOL administrative view
• DATAACCESS authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_DB_MEMORY_POOL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of memory pools and their current size for the currently connected database, SAMPLE.
POOL_ID POOL_CUR_SIZE
------------- --------------------
UTILITY 32768
PACKAGE_CACHE 475136
CAT_CACHE 65536
BP 2097152
BP 1081344
BP 540672
BP 278528
BP 147456
BP 81920
LOCK_MGR 294912
DATABASE 3833856
OTHER 0
12 record(s) selected.
Syntax
SNAP_GET_DB_MEMORY_POOL ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DB_MEMORY_POOL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
24 record(s) selected.
Information returned
Table 287. Information returned by the SNAPDB_MEMORY_POOL administrative view and the
SNAP_GET_DB_MEMORY_POOL table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
DB_NAME VARCHAR(128) db_name - Database name
Syntax
SNAP_GET_DB_V97 ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DB_V97 table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
1 record(s) selected.
Example 2: Retrieve the status, platform, location, and connect time as an aggregate view across all
database members for all active databases in the same instance that contains the currently connected
database.
Example 3: This routine can be used by calling the following on the command line:
When connected to a database:
1 record(s) selected.
Example 4: After running a workload, a user can use the following query with the table function.
Continued
...STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
1 record(s) selected.
Example 5: The following example shows how you can use the SNAP_GET_DB_V97 table function to
determine the status of a database:
SELECT SUBSTR
(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS
FROM table(SNAP_GET_DB_V97('hadrdb', 0))
DB_NAME DB_STATUS
-------------------- ----------------
HADRDB ACTIVE_STANDBY
Information returned
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPDBM administrative view
• CONTROL privilege on the SNAPDBM administrative view
Example
Retrieve database manager status and connection information for all database members.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DBM table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve the start time and current status of database member number 2.
DB2START_TIME DB2_STATUS
-------------------------- ------------
2006-01-06-14.59.59.062798 ACTIVE
Information returned
Table 289. Information returned by the SNAPDBM administrative view and the SNAP_GET_DBM table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
Authorization
One of the following authorizations is required:
• SELECT privilege on the SNAPDBM_MEMORY_POOL administrative view
• CONTROL privilege on the SNAPDBM_MEMORY_POOL administrative view
• DATAACCESS authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_DBM_MEMORY_POOL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of the memory pools and their current size for the database manager of the connected
database.
POOL_ID POOL_CUR_SIZE
-------------- --------------------
MONITOR 65536
OTHER 29622272
FCMBP 57606144
...
Syntax
SNAP_GET_DBM_MEMORY_POOL ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DBM_MEMORY_POOL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Information returned
Table 290. Information returned by the SNAPDBM_MEMORY_POOL administrative view and the
SNAP_GET_DBM_MEMORY_POOL table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
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:
• APP_GROUP
• APPL_CONTROL
• APPLICATION
• BP
• CAT_CACHE
• DATABASE
• DFM
• FCMBP
• IMPORT_POOL
• LOCK_MGR
• MONITOR
• OTHER
• PACKAGE_CACHE
• QUERY
• SHARED_SORT
• SORT
• STATEMENT
• STATISTICS
• UTILITY
Syntax
SNAP_GET_DBM_V95 ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DBM_V95 table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
Example
Retrieve the start time and current status of database member number 2.
DB2START_TIME DB2_STATUS
-------------------------- ------------
2006-01-06-14.59.59.062798 ACTIVE
Information returned
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPDETAILLOG administrative view
• CONTROL privilege on the SNAPDETAILLOG administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Retrieve log information for all database members for the currently connected database.
3 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DETAILLOG table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve log information for database member 1 for the currently connected database.
Information returned
Table 292. Information returned by the SNAPDETAILLOG administrative view and SNAP_GET_DETAILLOG
table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
DB_NAME VARCHAR(128) db_name - Database name
FIRST_ACTIVE_LOG BIGINT first_active_log - First active log file
number
LAST_ACTIVE_LOG BIGINT last_active_log - Last active log file
number
CURRENT_ACTIVE_LOG BIGINT current_active_log - Current active log
file number
CURRENT_ARCHIVE_LOG BIGINT current_archive_log - Current archive
log file number
DBPARTITIONNUM SMALLINT dbpartitionnum - Database partition
number monitor element
MEMBER SMALLINT member - Database member monitor
element
Syntax
SNAP_GET_DETAILLOG_V91 ( dbname )
, dbpartitionnum
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DETAILLOG_V91 table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve log information for database partition 1 for the currently connected database.
1 record(s) selected.
Syntax
SNAP_GET_DYN_SQL_V95 ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DYN_SQL_V95 table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of dynamic SQL run on the currently connected database member of the currently
connected database, ordered by the number of rows read.
PREP_TIME_WORST ...
-------------------- ...
0 ...
3 ...
...
4 ...
...
4 ...
...
4 ...
...
3 ...
...
4 ...
...
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
SELECT STATS_FABRICATE_TIME,SYNC_RUNSTATS_TIME
FROM SYSIBMADM.SNAPDYN_SQL
STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
---------------------- ------------------
5 10
3 20
2 record(s) selected.
Information returned
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPFCM administrative view
• CONTROL privilege on the SNAPFCM administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_FCM table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
Example
Retrieve information about the fast communication manager's message buffers on all members.
Syntax
SNAP_GET_FCM ( )
member
Example
Retrieve information about the fast communication manager's message buffers on database member 1.
Information returned
Table 295. Information returned by the SNAPFCM administrative view and the SNAP_GET_FCM table
function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
BUFF_FREE BIGINT buff_free - FCM buffers currently free
BUFF_FREE_BOTTOM BIGINT buff_free_bottom - Minimum FCM
Buffers Free
CH_FREE BIGINT ch_free - Channels Currently Free
CH_FREE_BOTTOM BIGINT ch_free_bottom - Minimum Channels
Free
DBPARTITIONNUM SMALLINT dbpartitionnum - Database partition
number monitor element
MEMBER SMALLINT member - Database member monitor
element
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPFCM_PART administrative view
• CONTROL privilege on the SNAPFCM_PART administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_FCM_PART table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
1 record(s) selected.
Syntax
SNAP_GET_FCM_PART ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_FCM_PART table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve buffers sent and received information for the fast communication manager for all members.
Information returned
Table 296. Information returned by the SNAPFCM_PART administrative view and the
SNAP_GET_FCM_PART table function
Column name Data type Description or corresponding 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:
• INACTIVE
• ACTIVE
• CONGESTED
Authorization
One of the following authorizations is required:
• SELECT privilege on the SNAPHADR administrative view
• CONTROL privilege on the SNAPHADR administrative view
• DATAACCESS authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_HADR table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve the configuration and status information for HADR on the primary HADR database.
1 record(s) selected.
Syntax
SNAP_GET_HADR ( dbname )
, member
Example
Retrieve the configuration and status information for HADR for all databases.
2 record(s) selected.
Information returned
Table 297. Information returned by the SNAPHADR administrative view and the SNAP_GET_HADR table
function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
DB_NAME VARCHAR(128) db_name - Database name
HADR_ROLE VARCHAR(10) hadr_role - HADR role. This interface
returns a text identifier based on the
defines in sqlmon.h, and is one of:
• PRIMARY
• STANDARD
• STANDBY
Authorization
One of the following authorizations is required:
• SELECT privilege on the SNAPLOCK administrative view
• CONTROL privilege on the SNAPLOCK administrative view
• DATAACCESS authority
Example
Retrieve lock information for the database member 0 of the currently connected database.
1 record(s) selected.
Syntax
SNAP_GET_LOCK ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_LOCK table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve lock information for the current database member of the currently connected database.
2 record(s) selected.
Information returned
Table 298. Information returned by the SNAPLOCK administrative view and the SNAP_GET_LOCK table
function
Column name Data type Description or corresponding 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
Authorization
One of the following authorizations is required:
• SELECT privilege on the SNAPLOCKWAIT administrative view
• CONTROL privilege on the SNAPLOCKWAIT administrative view
• DATAACCESS authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_LOCKWAIT table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve lock wait information for database member 0 for the currently connected database.
1 record(s) selected.
Syntax
SNAP_GET_LOCKWAIT ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_LOCKWAIT table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve lock wait information for current database member for the currently connected database.
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:
The default setting can also be turned on through the ADMIN_CMD stored procedure. For example:
If the ADMIN_CMD stored procedure is used or if the clp command is used without having previously
attached to the instance, the instance must be recycled before the change takes effect.
Information returned
Table 299. Information returned by the SNAPLOCKWAIT administrative view and the
SNAP_GET_LOCKWAIT table function
Column name Data type Description or corresponding 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
LOCK_MODE VARCHAR(10) lock_mode - Lock mode. This interface
returns a text identifier based on the
defines in sqlmon.h and is one of:
• IN
• IS
• IX
• NON (if no lock)
• NS
• NW
• S
• SIX
• U
• X
• Z
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPTBSP_RANGE administrative view
• CONTROL privilege on the SNAPTBSP_RANGE administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_TBSP_RANGE table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Select information about table space ranges for all database members for the currently connected
database.
5 record(s) selected.
Syntax
SNAP_GET_TBSP_RANGE ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TBSP_RANGE table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Select information about the table space range for the table space with tbsp_id = 2 on the currently
connected database member.
1 record(s) selected.
Table 300. Information returned by the SNAPTBSP_RANGE administrative view and the
SNAP_GET_TBSP_RANGE table function
Column name Data type Description or corresponding 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_container - Number of
containers in range
RANGE_CONTAINER_ID BIGINT range_container_id - Range container
DBPARTITIONNUM SMALLINT dbpartitionnum - Database partition
number monitor element
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPSTMT administrative view
• CONTROL privilege on the SNAPSTMT administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_STMT table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve rows read, written and operation performed for statements executed on the currently connected
single-member database.
2 record(s) selected.
Syntax
SNAP_GET_STMT ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_STMT table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Information returned
Table 301. Information returned by the SNAPSTMT administrative view and the SNAP_GET_STMT table
function
Column name Data type Description or corresponding 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)
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
NUM_AGENTS BIGINT num_agents - Number of agents working
on a statement
AGENTS_TOP BIGINT agents_top - Number of agents created
STMT_TYPE VARCHAR(20) stmt_type - Statement type. This
interface returns a text identifier based
on defines in sqlmon.h and is one of:
• DYNAMIC
• NON_STMT
• STATIC
• STMT_TYPE_UNKNOWN
SNAP_GET_STO_PATHS
The SNAP_GET_STO_PATHS table function returns snapshot information from the storage_paths logical
data group.
Note: This table function has been deprecated and replaced by the “ADMIN_GET_STORAGE_PATHS table
function - retrieve automatic storage path information” on page 164.
Authorization
One of the following authorities is required to execute the function:
• EXECUTE privilege on the function
• DATAACCESS authority
To access snapshot monitor data, one of the following authorities is required:
• SYSMON authority
• SYSCTRL authority
• SYSMAINT authority
• SYSADM authority
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPSTORAGE_PATHS administrative view
• CONTROL privilege on the SNAPSTORAGE_PATHS administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following authorizations is required to use the table function:
• EXECUTE privilege on the SNAP_GET_STORAGE_PATHS_V97 table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
To access snapshot monitor data, one of the following authorities is also required:
• SYSMON authority
• SYSCTRL authority
• SYSMAINT authority
• SYSADM authority
Example
Retrieve the storage path for the currently connected single-member database.
1 record(s) selected.
SNAP_GET_STORAGE_PATHS_V97
The SNAP_GET_STORAGE_PATHS_V97 table function returns similar information as the
SNAPSTORAGE_PATHS administrative view. It allows you to retrieve the information for a specific
database on a specific database member, aggregate of all database members or all database members.
Used with the SNAP_GET_DB, SNAP_GET_DETAILLOG, SNAP_GET_HADR and
SNAP_GET_DB_MEMORY_POOL table functions, the SNAP_GET_STORAGE_PATHS_V97 table function
provides information equivalent to the GET SNAPSHOT FOR ALL DATABASES CLP command.
Refer to Table 303 on page 1418 for a complete list of information that can be returned.
Syntax
SNAP_GET_STORAGE_PATHS_V97 ( dbname )
, member
Authorization
• EXECUTE privilege on the SNAP_GET_STORAGE_PATHS_V97 table function.
• DATAACCESS authority
To access snapshot monitor data, one of the following authorities is required:
• SYSMON authority
• SYSCTRL authority
• SYSMAINT suthority
Examples
Retrieve the storage path information for all active databases.
DB_NAME DB_STORAGE_PATH
-------- -------------------...
STOPATH /home/jessicae/sdb
MYDB /home/jessicae/mdb
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 303. Information returned by the SNAPSTORAGE_PATHS administrative view and the
SNAP_GET_STORAGE_PATHS_V97 table function
Column name Data type Description or corresponding 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
DB_STORAGE_PATH_WITH_DPE VARCHAR(256) db_storage_path_with_dpe - Storage
path including database partition
expression monitor element
DBPARTITIONNUM SMALLINT dbpartitionnum - Database partition
number monitor element
DB_STORAGE_PATH_STATE VARCHAR(16) db_storage_path_state - Storage path
state monitor element
FS_ID VARCHAR(22) fs_id - Unique file system identification
number
FS_TOTAL_SIZE BIGINT fs_total_size - Total size of a file system
FS_USED_SIZE BIGINT fs_used_size - Amount of space used on
a file system
STO_PATH_FREE_SIZE BIGINT sto_path_free_size - Automatic storage
path free space
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPTAB administrative view
• CONTROL privilege on the SNAPTAB administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_TAB table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
1 record selected.
Syntax
SNAP_GET_TAB ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TAB table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
Example
Retrieve a list of active tables as an aggregate view for the currently connected database.
Information returned
Table 304. Information returned by the SNAPTAB administrative view and the SNAP_GET_TAB table
function
Column name Data type Description or corresponding 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:
• CATALOG_TABLE
• DROPPED_TABLE
• REORG_TABLE
• SYNOPSIS_TABLE
• TEMP_TABLE
• USER_TABLE
SNAP_GET_TAB_V91
The SNAP_GET_TAB_V91 table function returns snapshot information from the table logical data group.
Important: The SNAP_GET_TAB_V91 table function is deprecated. Use the “MON_GET_TABLE table
function - get table metrics” on page 814 to retrieve the information returned by this deprecated
interface.
Refer to Table 305 on page 1423 for a complete list of information that can be returned.
Syntax
SNAP_GET_TAB_V91 ( dbname )
, dbpartitionnum
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TAB_V91 table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of active tables as an aggregate view for the currently connected database.
Information returned
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPTBSP administrative view
• CONTROL privilege on the SNAPTBSP administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_TBSP table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of table spaces on the catalog database member for the currently connected database.
2 record(s) selected.
Syntax
SNAP_GET_TBSP ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TBSP table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of table spaces for all database members for the currently connected database.
8 record(s) selected.
Information returned
Table 306. Information returned by the SNAPTBSP administrative view and the SNAP_GET_TBSP table
function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
TBSP_NAME VARCHAR(128) tablespace_name - Table space name
TBSP_ID BIGINT tablespace_id - Table space
identification
TBSP_TYPE VARCHAR(10) tablespace_type - Table space type.
This interface returns a text identifier
based on defines in sqlutil.h, and is
one of:
• DMS
• SMS
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPTBSP_RANGE administrative view
Example
Retrieve a list of table spaces and their state for all database partitions of the currently connected
database.
5 record(s) selected.
Syntax
SNAP_GET_TBSP_PART ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TBSP_PART table function.
• DATAACCESS authority
To access snapshot monitor data, one of the following authorities is also required:
• SYSMON authority
• SYSCTRL authority
• SYSMAINT authority
• SYSADM authority
Example
Retrieve a list of table spaces and their state for the connected database partition of the connected
database.
5 record(s) selected.
Table 307. Information returned by the SNAPTBSP_PART administrative view and the
SNAP_GET_TBSP_PART table function
Column name Data type Description or corresponding monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was taken.
TBSP_NAME VARCHAR (128) tablespace_name - Table space name
TBSP_ID BIGINT tablespace_id - Table space identification
TBSP_STATE VARCHAR (256) tablespace_state - Table space state. This
interface returns a text identifier based on defines
in sqlutil.h and is combination of the following
separated by a '+' sign:
• BACKUP_IN_PROGRESS
• BACKUP_PENDING
• DELETE_PENDING
• DISABLE_PENDING
• DROP_PENDING
• LOAD_IN_PROGRESS
• LOAD_PENDING
• NORMAL
• OFFLINE
• PSTAT_CREATION
• PSTAT_DELETION
• QUIESCED_EXCLUSIVE
• QUIESCED_SHARE
• QUIESCED_UPDATE
• REBAL_IN_PROGRESS
• REORG_IN_PROGRESS
• RESTORE_IN_PROGRESS
• RESTORE_PENDING
• ROLLFORWARD_IN_PROGRESS
• ROLLFORWARD_PENDING
• STORDEF_ALLOWED
• STORDEF_CHANGED
• STORDEF_FINAL_VERSION
• STORDEF_PENDING
• SUSPEND_WRITE
Syntax
SNAP_GET_TBSP_PART_V97 ( dbname )
, member
Authorization
• EXECUTE privilege on the SNAP_GET_TBSP_PART_V97 table function.
• DATAACCESS authority
To access snapshot monitor data, one of the following authorities is required:
• SYSMON authority
• SYSCTRL authority
• SYSMAINT authority
• SYSADM authority
Example
Retrieve a list of table spaces and their state for the connected database member of the connected
database.
5 record(s) selected.
Information returned
SNAP_GET_TBSP_V91
The SNAP_GET_TBSP_V91 table function returns snapshot information from the table space logical data
group.
Important: The SNAP_GET_TBSP_V91 table function is deprecated and have been replaced by the
“MON_GET_TABLESPACE table function - Get table space metrics” on page 820.
Refer to Table 309 on page 1440 for a complete list of information that can be returned.
Syntax
SNAP_GET_TBSP_V91 ( dbname )
, dbpartitionnum
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TBSP_V91 table function
• DATAACCESS authority
Example
Retrieve a list of table spaces for all database partitions for the currently connected database.
8 record(s) selected.
Information returned
Example
Retrieve information about the quiesced table spaces for all database members for the currently
connected database.
2 record(s) selected.
3 record(s) selected.
Use the given TBSPACEID and TABLEID provided from this query to find the table schema and name from
SYSCAT.TABLES.
TABSCHEMA TABNAME
------------ --------
SAMP ORDERS_RP
SAMP ORDERS_DMART
2 record(s) selected.
TABSCHEMA TABNAME
------------ --------
SAMP NATION
1 record(s) selected.
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_TBSP_QUIESCER table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve information about the quiesced table spaces for database member 1 for the currently connected
database.
1 record(s) selected.
Information returned
Table 310. Information returned by the SNAPTBSP_QUIESCER administrative view and the
SNAP_GET_TBSP_QUIESCER table function
Column name Data type Description or corresponding 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
QUIESCER_STATE VARCHAR(14) quiescer_state - Quiescer state. This
interface returns a text identifier based
on defines in sqlutil.h and is one of:
• EXCLUSIVE
• UPDATE
• SHARE
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPUTIL administrative view
• CONTROL privilege on the SNAPUTIL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_UTIL table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of utilities and their states on all database members for all active databases in the instance
that contains the connected database.
3 record(s) selected.
Syntax
SNAP_GET_UTIL ( )
member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_UTIL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Example 1: Retrieve a list of utility ids with their type and state for the currently connected database
member on database SAMPLE.
1 record(s) selected.
Example 2: Retrieve a list of utility ids with their type, member number and database partition number for
the currently connected database member.
Information returned
Table 311. Information returned by the SNAPUTIL administrative view and the SNAP_GET_UTIL table
function
Column name Data type Description or corresponding 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.
UTILITY_TYPE VARCHAR(26) utility_type - Utility type. This interface
returns a text identifier based on the
defines in sqlmon.h.
UTILITY_PRIORITY INTEGER utility_priority - Utility priority. Priority if
utility supports throttling, otherwise null.
UTILITY_DESCRIPTION VARCHAR(2048) utility_description - Utility description.
Can be null.
UTILITY_DBNAME VARCHAR(128) utility_dbname - Database operated on
by utility
UTILITY_START_TIME TIMESTAMP utility_start_time - Utility start time
UTILITY_STATE VARCHAR(10) utility_state - Utility state. This interface
returns a text identifier based on the
defines in sqlmon.h.
SNAP_WRITE_FILE procedure
The SNAP_WRITE_FILE procedure writes system snapshot data to a file in the tmp subdirectory of the
instance directory.
Important: The SNAP_WRITE_FILE procedure is deprecated and might be removed in a future release.
Start using the monitoring SQL interfaces. If you still need to write snapshot data to a file, use other
methods before this procedure becomes discontinued.
Syntax
SNAP_WRITE_FILE ( requestType , dbname , member )
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:
• APPL_ALL
• BUFFERPOOLS_ALL
• DB2
• DBASE_ALL
• DBASE_LOCKS
• DBASE_TABLES
• DBASE_TABLESPACES
• DYNAMIC_SQL
dbname
An input argument of type VARCHAR(128) 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
Authorization
One of the following authorizations is required to execute the procedure:
• EXECUTE privilege on the procedure
• DATAACCESS authority
To access snapshot monitor data, one of the following authorities is also required:
• SYSMON authority
• SYSCTRL authority
• SYSMAINT authority
• SYSADM authority
Note: If you do not have SYSMON, SYSCTRL, SYSMAINT, or SYSADM authority, you can read the saved
snapshot data by passing null values as the inputs to snapshot functions.
Example
Take a snapshot of database manager information by specifying a request type of 'DB2' (which
corresponds to SQLMA_DB2), and defaulting to the currently connected database and current database
partition.
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
If an unrecognized input parameter is provided, the following error is returned: SQL2032N The
"REQUEST_TYPE" parameter is not valid.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPAGENT administrative view
• CONTROL privilege on the SNAPAGENT administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_AGENT table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve all application snapshot information for the currently connected database from the agent logical
data group.
Syntax
SNAP_GET_AGENT ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_AGENT table function
• DATAACCESS authority
Example
Retrieve all application snapshot information for all applications in all active databases.
6 record(s) selected.
Information returned
Table 312. Information returned by the SNAPAGENT administrative view and the SNAP_GET_AGENT table
function
Column name Data type Description or corresponding 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 dbpartitionnum - Database partition
number monitor element
Authorization
One of the following is required to use the view:
• SELECT privilege on the SNAPAGENT_MEMORY_POOL administrative view
• CONTROL privilege on the SNAPAGENT_MEMORY_POOL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_AGENT_MEMORY_POOL table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Retrieve a list of memory pools and their current size.
9 record(s) selected.
Syntax
SNAP_GET_AGENT_MEMORY_POOL ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_AGENT_MEMORY_POOL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve a list of memory pools and their current size for all databases.
18 record(s) selected.
Table 313. Information returned by the SNAPAGENT_MEMORY_POOL administrative view and the
SNAP_GET_AGENT_MEMORY_POOL table function
Column name Data type Description or corresponding 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)
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:
• APP_GROUP
• APPL_CONTROL
• APPLICATION
• BP
• CAT_CACHE
• DATABASE
• DFM
• FCMBP
• IMPORT_POOL
• LOCK_MGR
• MONITOR
• OTHER
• PACKAGE_CACHE
• QUERY
• SHARED_SORT
• SORT
• STATEMENT
• STATISTICS
• UTILITY
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPAPPL_INFO administrative view
• CONTROL privilege on the SNAPAPPL_INFO administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_APPL_INFO table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Also, one of the following authorities is required:
• SYSMON
• SYSMAINT
• SYSCTRL
• SYSADM
Example
Retrieve the status of the applications connected to the current database.
2 record(s) selected.
Syntax
SNAP_GET_APPL_INFO ( dbname )
, member
Examples
Retrieve the status of all applications on the connected database member.
4 record(s) selected.
The following shows what you obtain when you SELECT from the result of the table function.
DB_NAME AUTHORITY_LVL
-------- -----------------------------------------------------....
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
TESTDB SYSADM(GROUP) + DBADM(USER) + CREATETAB(USER, GROUP) +
BINDADD(USER, GROUP) + CONNECT(USER, GROUP) +
CREATE_NOT_FENC(USER) + IMPLICIT_SCHEMA(USER, GROUP) +
LOAD(USER) + CREATE_EXT_RT(USER) + QUIESCE_CONN(USER)
3 record(s) selected.
Table 314. Information returned by the SNAPAPPL_INFO administrative view and the
SNAP_GET_APPL_INFO table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
AGENT_ID BIGINT agent_id - Application handle (agent ID)
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:
• BACKUP
• COMMIT_ACT
• COMP
• CONNECTED
• CONNECTPEND
• CREATE_DB
• DECOUPLED
• DISCONNECTPEND
• INTR
• IOERROR_WAIT
• LOAD
• LOCKWAIT
• QUIESCE_TABLESPACE
• RECOMP
• REMOTE_RQST
• RESTART
• RESTORE
• ROLLBACK_ACT
• ROLLBACK_TO_SAVEPOINT
• TEND
• THABRT
• THCOMT
• TPREP
• UNLOAD
• UOWEXEC
• UOWWAIT
• WAITFOR_REMOTE
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPAPPL administrative view
• CONTROL privilege on the SNAPAPPL administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
Example
Retrieve details on rows read and written for each application in the connected database.
1 record(s) selected.
Syntax
SNAP_GET_APPL ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_APPL table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve details on rows read and written for each application for all active databases.
Table 315. Information returned by the SNAPAPPL administrative view and the SNAP_GET_APPL table
function
Column name Data type Description or corresponding 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 inact_stmthist_sz - 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
POOL_TEMP_DATA_P_READS BIGINT pool_temp_data_p_reads - Buffer pool
temporary data physical reads
POOL_TEMP_INDEX_L_READS BIGINT pool_temp_index_l_reads - Buffer pool
temporary index logical reads
POOL_TEMP_INDEX_P_READS BIGINT pool_temp_index_p_reads - Buffer pool
temporary index physical reads
POOL_TEMP_XDA_L_READS BIGINT pool_temp_xda_l_reads - Buffer Pool
Temporary XDA Data Logical Reads
POOL_TEMP_XDA_P_READS BIGINT pool_temp_xda_p_reads - Buffer Pool
Temporary XDA Data Physical Reads
monitor element
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
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPBP administrative view
• CONTROL privilege on the SNAPBP administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_BP table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve data and index writes for all the bufferpools of the currently connected database.
5 record(s) selected
Syntax
SNAP_GET_BP ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_BP table function
• DATAACCESS authority
Example
Retrieve total physical and logical reads for all bufferpools for all active databases for the currently
connected database member.
3 record(s) selected.
Information returned
Table 316. Information returned by the SNAPBP administrative view and the SNAP_GET_BP table function
Column name Data type Description or corresponding 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
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPBP_PART administrative view
• CONTROL privilege on the SNAPBP_PART administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_BP_PART table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Syntax
SNAP_GET_BP_PART ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_BP_PART table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Example
Retrieve data for all bufferpools for all active databases when connected to the SAMPLE database.
...
...
Table 317. Information returned by the SNAPBP_PART administrative view and the SNAP_GET_BP_PART
table function
Column name Data type Description or corresponding 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
BP_CUR_BUFFSZ BIGINT bp_cur_buffsz - current size of buffer
pool
BP_NEW_BUFFSZ BIGINT bp_new_buffsz - New buffer pool size
BP_PAGES_LEFT_TO_REMOVE BIGINT bp_pages_left_to_remove - Number of
pages left to remove
BP_TBSP_USE_COUNT BIGINT bp_tbsp_use_count - Number of table
spaces mapped to buffer pool
DBPARTITIONNUM SMALLINT dbpartitionnum - Database partition
number monitor element
MEMBER SMALLINT member - Database member monitor
element
Example
Retrieve details for the table space containers for all database members for the currently connected
database.
Syntax
SNAP_GET_CONTAINER ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_CONTAINER table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
Example
Retrieve details for the table space containers on the currently connected database on the currently
connected database member.
Information returned
NOTE: The BUFFERPOOL database manager monitor switch must be turned on in order for the file system
information to be returned.
Table 318. Information returned by the SNAPCONTAINER administrative view and the
SNAP_GET_CONTAINER table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
Authorization
One of the following authorizations is required to use the view:
• SELECT privilege on the SNAPDB administrative view
• CONTROL privilege on the SNAPDB administrative view
• DATAACCESS authority
• DBADM authority
• SQLADM authority
• ACCESSCTRL authority
• SECADM authority
One of the following is required to use the table function:
• EXECUTE privilege on the SNAP_GET_DB table function
• DATAACCESS authority
• DBADM authority
• SQLADM authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Retrieve the status, platform, location, and connect time for all database members of the currently
connected database.
This routine can be used by calling the following on the command line:
1 record(s) selected.
1 record(s) selected.
Syntax
SNAP_GET_DB ( dbname )
, member
Authorization
One of the following authorizations is required:
• EXECUTE privilege on the SNAP_GET_DB table function
• DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
• SYSMON
• SYSCTRL
• SYSMAINT
• SYSADM
Examples
Example 1: Retrieve the status, platform, location, and connect time as an aggregate view across all
database members of the currently connected database.
1 record(s) selected.
Example 2: Retrieve the status, platform, location, and connect time as an aggregate view across all
database members for all active databases in the same instance that contains the currently connected
database.
Example 3: This routine can be used by calling the following on the command line:
When connected to a database:
1 record(s) selected.
Example 4: After running a workload, a user can use the following query with the table function.
Continued
...STATS_FABRICATE_TIME SYNC_RUNSTATS_TIME
...-------------------- ------------------
... 2 32
1 record(s) selected.
Example 5: The following example shows how you can use the SNAP_GET_DB table function to determine
the status of a database:
SELECT SUBSTR
(DB_NAME, 1, 20) AS DB_NAME, DB_STATUS
FROM table(SNAP_GET_DB('hadrdb', 0))
DB_NAME DB_STATUS
-------------------- ----------------
HADRDB ACTIVE_STANDBY
Information returned
Table 319. Information returned by the SNAPDB administrative view and SNAP_GET_DB table function
Column name Data type Description or corresponding monitor
element
SNAPSHOT_TIMESTAMP TIMESTAMP The date and time that the snapshot was
taken.
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