sqle_activate_db API - Activate database
Activates the specified database and starts up all associated database services, so that the database is available for connection and use by any application.
Scope
Authorization
- SYSADM
- SYSCTRL
- SYSMAINT
Required connection
None. Applications invoking ACTIVATE DATABASE cannot have any existing database connections.
API include file
sqlenv.h
API and data structure syntax
SQL_API_RC SQL_API_FN
db2ActivateDb (
db2Uint32 versionNumber,
void * pDB2ActivateDbStruct,
struct sqlca * pSqlca);
typedef SQL_STRUCTURE db2ActivateDbStruct
{
char * piDbAlias;
char * piUserName;
char * piPassword;
db2Uint32 iOptions;
} db2ActivateDbStruct;
db2ActivateDb API parameters
- versionNumber
- Input. Specifies the version and release level of the structure passed as the second parameter data.
- pDB2ActivateDbStruct
- Input. Pointer to the db2ActivateDbStruct structure.
- pSqlca
- Output. Pointer to the sqlca structure.
db2ActivateDbStruct data structure parameters
- piDbAlias
- Input. Pointer to the database alias name.
- piUserName
- Input. Pointer to the user ID starting the database. Can be NULL.
- piPassword
- Input. Pointer to the password for the user name. Can be NULL, but must be specified if a user name is specified.
- iOptions
- Input. Reserved for future use.
sqle_activate_db API parameters
- pDbAlias
- Input. Pointer to the database alias name.
- pUserName
- Input. Pointer to the user ID starting the database. Can be NULL.
- pPassword
- Input. Pointer to the password for the user name. Can be NULL, but must be specified if a user name is specified.
- pReserved
- Reserved for future use.
- pSqlca
- Output. Pointer to the sqlca structure.
sqlg_activate_db API-specific parameters
- DbAliasLen
- Input. A 2-byte unsigned integer representing the length of the database alias name in bytes.
- UserNameLen
- Input. A 2-byte unsigned integer representing the length of the user name in bytes. Set to zero if no user name is supplied.
- PasswordLen
- Input. A 2-byte unsigned integer representing the length of the password in bytes. Set to zero if no password is supplied.
Examples
This section provides an example of a database activation scenario. The following code block is a common body program that will be used for the database activation scenarios.
struct sqlca sqlca; // sqlca to carry the sqlcode
struct db2ActivateDbStruct activateDbStruct;
struct db2ActDeactMemberStruct memberList;
strcpy(activateDbStruct->piUserName, "USER1"); //local instance
The following activate API is shown common to the scenarios listed in the following examples:
db2ActivateDb( db2Version, &activateDbStruct, &sqlca );
- Activate a database globally across all members
activateDbStruct.iOptions = DB2_ACTDEACT_DB_GLOBAL; activateDbStruct->piMemberList = NULL;
- Activate a database at an individual member 20
activateDbStruct.iOptions = DB2_ACTDEACT_DB_MEMBER; activateDbStruct->piMemberList->numMembers = 1; activateDbStruct->piMemberList->pMember[0] = 20;
Usage notes
Database administrators can use ACTIVATE DATABASE to start selected databases. This eliminates any application time spent on database initialization.
In a Db2 pureScale environment, when the ACTIVATE DATABASE command is issued by a client using the TCP/IP protocol, the command is assigned to a member subset which includes a set of members in the instance. If the database alias used is not associated with any user defined member subset, the command is assigned to the default member subset which includes all members in the instance. Database administrators can use this functionality to activate a database on a subset of the members in the instance.
Databases initialized by ACTIVATE DATABASE can only be shut down by sqle_deactivate_db, or by db2InstanceStop. To obtain a list of activated databases, you may invoke the db2GetSnapshot. API
If a database was started by a DB2 CONNECT TO command (or by an implicit connect), and subsequently an ACTIVATE DATABASE is issued for that same database, then DEACTIVATE DATABASE must also be used to shut down that database.
See the autorestart configuration parameter for database connection behavior when the target database is in an inconsistent state.
REXX API syntax
This API can be called from REXX through the SQLDB2 interface.