DB2 Version 10.1 for Linux, UNIX, and Windows

db2DatabaseRestart API - Restart database

Restarts a database that has been abnormally terminated and left in an inconsistent state. At the successful completion of this API, the application remains connected to the database if the user has CONNECT privilege.

Scope

This API affects only the database partition where the API is run. In DB2® pureScale® environments, this API can be run from any member and can trigger, when needed, a group crash recovery, which performs the crash recovery for all members of the group, or to trigger a member crash recovery.

Authorization

None

Required connection

This API establishes a database connection.

API include file

db2ApiDf.h

API and data structure syntax

SQL_API_RC SQL_API_FN
  db2DatabaseRestart (
   db2Uint32 versionNumber,
   void * pParmStruct,
   struct sqlca * pSqlca);

typedef struct db2RestartDbStruct
{
   char *piDatabaseName;
   char *piUserId;
   char *piPassword;
   char *piTablespaceNames;
   db2int32 iOption;
} db2RestartDbStruct;

SQL_API_RC SQL_API_FN
  db2gDatabaseRestart (
   db2Uint32 versionNumber,
   void * pParmStruct,
   struct sqlca * pSqlca);

typedef struct db2gRestartDbStruct
{
   db2Uint32 iDatabaseNameLen;
   db2Uint32 iUserIdLen;
   db2Uint32 iPasswordLen;
   db2Uint32 iTablespaceNamesLen;
   char *piDatabaseName;
   char *piUserId;
   char *piPassword;
   char *piTablespaceNames;
} db2gRestartDbStruct;

db2DatabaseRestart API parameters

versionNumber
Input. Specifies the version and release level of the structure passed in as the second parameter, pParamStruct.
pParamStruct
Input. A pointer to the db2RestartDbStruct structure.
pSqlca
Output. A pointer to the sqlca structure.

db2RestartDbStruct data structure parameters

piDatabaseName
Input. A pointer to a string containing the alias of the database that is to be restarted.
piUserId
Input. A pointer to a string containing the user name of the application. May be NULL.
piPassword
Input. A pointer to a string containing a password for the specified user name (if any). Can be NULL.
piTablespaceNames
Input. A pointer to a string containing a list of table space names to be dropped during the restart operation. Can be NULL.
iOption
Input. Valid values are:
DB2_DB_SUSPEND_NONE
Performs normal crash recovery.
DB2_DB_RESUME_WRITE
Required to perform crash recovery on a database that has I/O write operations suspended. In DB2 pureScale environments, this option resumes I/O write operations for all suspended members.

db2gRestartDbStruct data structure specific parameters

iDatabaseNameLen
Input. Length in bytes of piDatabaseName parameter.
iUserIdLen
Input. Length in bytes of piUserId parameter.
iPasswordLen
Input. Length in bytes of piPassword parameter.
iTablespaceNamesLen
Input. Length in bytes of piTablespaceNames parameter.

Usage notes

Call this API if an attempt to connect to a database returns an error message, indicating that the database must be restarted. This action occurs only if the previous session with this database terminated abnormally (due to power failure, for example).

At the completion of this API, a shared connection to the database is maintained if the user has CONNECT privilege, and an SQL warning is issued if any indoubt transactions exist. In this case, the database is still usable, but if the indoubt transactions are not resolved before the last connection to the database is dropped, another call to the API must be completed before the database can be used again.

In the case of circular logging, a database restart operation will fail if there is any problem with the table spaces, such as an I/O error, an unmounted file system, and so on. If losing such table spaces is not an issue, their names can be explicitly specified; this will put them into drop pending state, and the restart operation can complete successfully.

REXX API syntax

RESTART DATABASE database_alias [USER username USING password]

REXX API parameters

database_alias
Alias of the database to be restarted.
username
User name under which the database is to be restarted.
password
Password used to authenticate the user name.