DB2 10.5 for Linux, UNIX, and Windows

SQLDropDb function (CLI) - Drop a database

The SQLDropDb() function drops the specified database.

Specification:

Unicode Equivalent: The corresponding Unicode function is the SQLDropDbW() function. For information about ANSI to Unicode function mappings, see Unicode functions (CLI).

Syntax

SQLRETURN SQL_API_FN SQLDropDb ( SQLHDBC      hDbc,
                                 SQLCHAR      *szDbName,
                                 SQLINTEGER   cbDbName); 

Function arguments

Table 1. SQLDropDb function argument
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.

Usage

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().

Return codes

Restrictions

Example

The following example creates and drops DB2 databases on a local server:
  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                     
The following example creates and drops DB2 databases on a remote server:
  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                  

Version information

Last update
This topic was last updated for IBM DB2 Version 9.7, Fix Pack 3.
IBM Data Server Client
Supported in IBM DB2 Database for Linux, UNIX, and Windows