-ACCESS DATABASE command (Db2)

The Db2 command ACCESS DATABASE forces a physical open of a table space, index space, or partition, or removes the GBP-dependent status for a table space, index space, or partition, or externalizes the real-time statistics and optimizer statistics recommendations from in-memory blocks to the appropriate catalog tables. The MODE keyword specifies the desired action.

Abbreviation: -ACC

Environment

This command can be issued from a z/OS® console, a DSN session under TSO, a DB2I panel (DB2 COMMANDS), an IMS or CICS® terminal, or a program using the instrumentation facility interface (IFI).

Data sharing scope: Group or member

Authorization

To execute this command, you must use a privilege set of the process that includes one of the following authorities:
  • STARTDB privilege
  • DBMAINT authority
  • DBCTRL authority
  • DBADM authority
  • SYSCTRL authority
  • SYSADM authority
  • System DBADM authority
When you are using a privilege set that does not contain the STARTDB privilege for a specified database, Db2 issues an error message and the ACCESS command fails.

All specified databases with the STARTDB privilege included in the privilege set of the process are started.

Db2 commands that are issued from a logged-on z/OS console or TSO SDSF can be checked by Db2 authorization using primary and secondary authorization IDs. Start of changeA logged-on z/OS user ID must be defined in RACF or a similar security server.End of change

When data definition control is active, installation SYSOPR or installation SYSADM authority is required to start a database, a table space, or an index space containing a registration table or index.

Syntax

Read syntax diagramSkip visual syntax diagramACCESSDATABASE(,database-name*dbname1: dbname2dbname**dbname*dbname**dbstring1*dbstring2*)SPACENAM( ,space-name*spacename1: spacename2spacename**spacename*spacename**spacestring1*spacestring2* )PART(,integerinteger1: integer2)MODE( OPENNGBPDEPSTATS )

Option descriptions

DATABASE (database-name,…)
Specifies the names of the database, or database for the table spaces or index spaces to access.

Abbreviation: DB

database-name
The name of one or more database to access. The following variations are accepted:
(database-name, ...)
Identifies one or more database names, separated by commas or blanks.
(*)
All databases that are defined to the Db2 subsystem for which the privilege set of the process has the required authorization.
(dbname1:dbname2)
All databases whose names, in UNICODE, are between dbname1 and dbname2 inclusive.
(dbname*)
All databases whose names begin with the string dbname that contains 1–7 characters.
(*dbname)
All databases whose names end with the string dbname that contains 1–7 characters.
(*dbname*)
All databases whose names contain the string dbname,where dbname that contains 1–6 characters.
(*dbstring1*dbstring2*)
All databases whose names contain the strings dbstring1 and dbstring2 that together contain a total of 2–5 characters.
SPACENAM(space-name, …)
Indicates names of table spaces or indexes within the specified database to access.
Abbreviation: SPACE, SP
space-name
The name of one or more table spaces or index spaces to access. The following variations are accepted:
(spacename, ...)
One ore more index space names, separated by commas or blanks.
(*)
All table spaces or index spaces that are defined to the Db2 subsystem for which the privilege set of the process has the required authorization.
(spacename1:spacename2)
All table spaces or index spaces whose names, in UNICODE, are between spacename1 and spacename2 inclusive
(spacename*)
All table spaces or index spaces whose names begin with the string spacename that contains 1–7 characters.
(*spacename)
All table spaces or index spaces whose names end with the string spacename that contains 1–7 characters.
(*spacename*)
All table spaces or index spaces whose names contain the string spacename that contains 1–6 characters.
(*spacestring1*spacestring2*)
All table spaces or index spaces whose names contain the strings spacestring1 and spacestring2 that together contain a total of 2–5 characters.
PART(integer,)
Indicates the partition number of one or more partitions, within the specified table space or index, that are to be accessed.

The specified integer value must identify a valid partition number for the corresponding space name and database name. If you specify nonvalid partition numbers, you receive an error message for each non-valid number, but all valid partitions that you specified are accessed.

integer can be written to designate one of the following specifications:
  • A list of one or more partitions.
  • A range of all partition numbers that collate greater than or equal to integer-1 and less than or equal to integer-2.
  • A combination of lists and ranges.

PART is valid with partitioned table spaces, partitioned indexes, and nonpartitioned type 2 indexes of partitioned table spaces. If you specify PART with a nonpartitioned table space or index on a nonpartitioned table space, you receive an error message, and the nonpartitioned space is not accessed. When a logical partition is accessed, the index is not closed. A nonpartitioning index must be accessed without the use of PART to close the index.

MODE( mode-value )
Specifies the action for the command, where mode-value is one of the following values:
OPEN
Forces the physical opening of the page set or partition on just the local member. This moves the overhead of the physical open from an SQL thread to the command thread. This improves the transaction rate for the first SQL thread to reference a given page set or partition.

When MODE(OPEN) is specified, Db2 does not process objects with the following characteristics:

  • The objects are defined with DEFINE NO.
  • The physical data sets for the objects have not been created.
NGBPDEP
Start of changeRemoves group buffer pool dependency from the specified page set or partition. Use this before running large batch processes against a particular page set or partition to improve performance in a data sharing environment. Issue this command only on the same member that runs the batch processes. The page set or partition is drained when you specify this keyword.End of change
STATS
Externalizes the in-memory real-time statistics and the optimizer recommendations to the appropriate catalog tables. In data sharing environments, the in-memory statistics are externalized for all members. This mode does not physically open the page sets or change the states of the page sets.

When the MODE (STATS) option is specified, only certain combinations of database-name and space-name values are recommended.

Usage notes

The following description contains additional information about how to use the ACCESS DATABASE command.

What to do if ACCESS DATABASE returns error message DSNI045I
Issuing ACCESS DATABASE MODE(OPEN) on several members of a data sharing group at the same time might result in error message DSNI045I and reason code 00C90090, due to resource contention. If this error occurs, reissue the ACCESS DATABASE MODE(OPEN) command to open all of the objects that the command affects. To avoid the error, do not issue ACCESS DATABASE MODE(OPEN) on multiple data sharing group members at the same time.
Trace information for commands issued with group scope
If this command is issued with options that specify group scope in a Db2 data sharing member, it also runs on all other active members. IFICID 090 trace records for other group members can show that the same command was issued by the SYSOPR authorization ID from the 016.TLPKN5F correlation ID, in addition to the trace records from the member where the original command was issued. See Command scope in Db2 data sharing.

Examples

Example: Physically opening partitions
This command physically opens partitions 1 and 3 of table space DSN9002 of database DSN9001.
-ACCESS DATABASE(DSN9001) SPACENAM(DSN9002) PART(1,3) MODE(OPEN)
Example: Physically closing a nonpartitioned table space
This command physically closes the entire nonpartitioned table space DSN9003 of database DSN9001 and makes it non-group bufferpool dependent.
-ACCESS DATABASE(DSN9001) SPACENAM(DSN9003) MODE(NGBPDEP)

Output similar to the following output indicates that the command completed successfully:

  -DSNTDDIS 'ACCESS DATABASE' NORMAL COMPLETION 
Example: Externalize all in memory statistics to the real-time statistics tables
The following command externalizes all in-memory statistics and optimizer recommended statistics that are currently held in the system to the real-time statistics table.
-ACCESS DB(*) SP(*) MODE(STATS)