The SQLDropDb() function drops the specified database.
SQLRETURN SQL_API_FN SQLDropDb ( SQLHDBC hDbc,
SQLCHAR *szDbName,
SQLINTEGER cbDbName);
Data type | Argument | Use | Description |
---|---|---|---|
SQLHDBC | hDbc | input | Connection handle. |
SQLCHAR * | szDbName | input | Name of the database that is to be dropped. |
SQLINTEGER | cbDbName | input | Number of SQLCHAR elements (or SQLWCHAR elements for the Unicode variant of the function) that is needed to store the szDbName argument or to store SQL_NTS if the szDbName is null terminated. |
To drop a DB2® database, the CLI application must first attach to the server instance by using the ATTACH keyword. The valid APIs, after connecting to the server instance using ATTACH keyword are SQLCreateDb(), SQLDropDb(), and SQLDisconnect().
sqldriverconnect 1 0 "attach=true" -3 50 SQL_DRIVER_NOPROMPT
sqlcreatedb 1 sample1 8 null 0 null 0
sqlcreatedb 1 sample2 8 null 0 null 0
sqldropdb 1 sample1 8
sqldropdb 1 sample2 8
sqldisconnect 1
sqldriverconnect 1 0 "attach=true;hostname=myhostname;port=9999;
uid=myuid;pwd=mypwd;protocol=tcpip" -3 50 SQL_DRIVER_NOPROMPT
sqlcreatedb 1 sample1 8 null 0 null 0
sqlcreatedb 1 sample2 8 null 0 null 0
sqldropdb 1 sample1 8
sqldropdb 1 sample2 8
sqldisconnect 1