Linux: Reference: DB2 commands for Tivoli Storage Manager server databases

Use this list as reference when you are directed to issue DB2® commands by IBM® support.

Purpose


After using the wizards
to install and configure Tivoli® Storage
Manager, you seldom
need to issue DB2 commands.
A limited set of DB2 commands
that you might use or be asked to issue are listed in Table 1. This list is supplemental
material only and is not a comprehensive list. There is no implication
that a Tivoli Storage
Manager administrator
will use it on a daily or ongoing basis. Samples of some commands
are provided. Details of output are not listed. 

For a full explanation of the commands described here and of their syntax, see http://www.ibm.com/support/knowledgecenter/SSEPGG_10.5.0.

Table 1. DB2 commands
Command Description Example
db2icrt
Creates DB2 instances in the home directory of the instance owner.
Tip: The Tivoli Storage Manager configuration wizard creates the instance used by the server and database. After a server is installed and configured through the configuration wizard, the db2icrt command is generally not used.

Linux operating systemsThis utility is in the DB2DIR/instance directory, where DB2DIR represents the installation location where the current version of the DB2 database system is installed.

Manually create a Tivoli Storage Manager instance. Enter the command on one line:
/opt/tivoli/tsm/db2/instance/
db2icrt -a server -u
instance_name instance_name
db2set Displays DB2 variables. List DB2 variables:
db2set
CATALOG DATABASE Stores database location information in the system database directory. The database can be located either on the local workstation or on a remote database partition server. The server configuration wizard takes care of any catalog needed for using the server database. Run this command manually, after a server is configured and running, only if something in the environment changes or is damaged. Catalog the database:
db2 catalog database tsmdb1 
CONNECT TO DATABASE Connects to a specified database for command-line interface (CLI) use. Connect to the Tivoli Storage Manager database from a DB2 CLI:
db2 connect to tsmdb1
GET DATABASE CONFIGURATION
Returns the values of individual entries in a specific database configuration file.
Important: This command and parameters are set and managed directly by DB2. They are listed here for informational purposes and a means to view the existing settings. Changing these settings might be advised by IBM support or through service bulletins such as APARs or Technical Guidance documents (technotes). Do not change these settings manually. Change them only at the direction of IBM and only through the use of Tivoli Storage Manager server commands or procedures.
Show the configuration information for a database alias:
db2 get db cfg for tsmdb1 
Retrieve information in order to verify settings such as database configuration, log mode, and maintenance.
db2 get db config for tsmdb1 
show detail 
GET DATABASE MANAGER CONFIGURATION
Returns the values of individual entries in a specific database configuration file.
Important: This command and parameters are set and managed directly by DB2. They are listed here for informational purposes and a means to view the existing settings. Changing these settings might be advised by IBM support or through service bulletins such as APARs or Technical Guidance documents (technotes). Do not change these settings manually. Change them only at the direction of IBM and only through the use of Tivoli Storage Manager server commands or procedures.
Retrieve configuration information for the database manager:
db2 get dbm cfg 
GET HEALTH SNAPSHOT Retrieves the health status information for the database manager and its databases. The information returned represents a snapshot of the health state at the time the command was issued. Tivoli Storage Manager monitors the state of the database using the health snapshot and other mechanisms that are provided by DB2. There might be cases where the health snapshot or other DB2 documentation indicates that an item or database resource might be in an alert state. Such a case indicates that action must be considered to remedy the situation. Tivoli Storage Manager monitors the condition and responds appropriately. Not all declared alerts by the DB2 database are acted on. Receive a report on DB2 health monitor indicators:
db2 get health snapshot for 
database on tsmdb1 
GRANT (Database Authorities) Grants authorities that apply to the entire database rather than privileges that apply to specific objects within the database. Grant access to the user ID itmuser:
db2 GRANT CONNECT ON DATABASE 
TO USER itmuser 
db2 GRANT CREATETAB ON DATABASE 
TO USER itmuser 
RUNSTATS Updates statistics about the characteristics of a table and associated indexes or statistical views. These characteristics include number of records, number of pages, and average record length.

To see a table, issue this utility after updating or reorganizing the table.

A view must be enabled for optimization before its statistics can be used to optimize a query. A view that is enabled for optimization is known as a statistical view. Use the DB2 ALTER VIEW statement to enable a view for optimization. Issue the RUNSTATS utility when changes to underlying tables substantially affect the rows returned by the view.

Tip: The server configures DB2 to run the RUNSTATS command as needed.
Update statistics on a single table.
db2 runstats on table 
SCHEMA_NAME.TABLE_NAME 
with distribution and sampled 
detailed indexes all 
SET SCHEMA Changes the value of the CURRENT SCHEMA special register, in preparation for issuing SQL commands directly through the DB2 CLI.
Tip: A special register is a storage area that is defined for an application process by the database manager. It is used to store information that can be referenced in SQL statements.
Set the schema for Tivoli Storage Manager:
 db2 set schema tsmdb1
START DATABASE MANAGER Starts the current database manager instance background processes. The Tivoli Storage Manager server starts and stops the instance and database whenever the server starts and halts.
Important: Allow the Tivoli Storage Manager server to manage the starting and stopping of the instance and database unless otherwise directed by IBM support.
Start the database manager:
db2start 
STOP DATABASE MANAGER Stops the current database manager instance. Unless explicitly stopped, the database manager continues to be active. This command does not stop the database manager instance if any applications are connected to databases. If there are no database connections, but there are instance attachments, the command forces the instance attachments to stop first. Then, it stops the database manager. This command also deactivates any outstanding database activations before stopping the database manager.

This command is not valid on a client.

The Tivoli Storage Manager server starts and stops the instance and database whenever the server starts and halts.

Important: Allow the Tivoli Storage Manager server to manage the starting and stopping of the instance and database unless otherwise directed by IBM support.
Stop the database manager:
db2 stop dbm