Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements >

DATABASE

Use the DATABASE statement to open an accessible database as the current database.

This statement is an extension to the ANSI/ISO standard for SQL.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DATABASE--database--+-----------+---------------------------><
                       '-EXCLUSIVE-'
 
Element Description Restrictions Syntax
database Name of the database The database must exist Database Name

Usage

You can use the DATABASE statement to select any database on your database server. To select a database on another database server, specify the name of the database server with the database name.

If you include the name of the current (or another) database server with the database name, the database server name cannot be uppercase. (See Database Name for the syntax of specifying the database server name.)

Issuing a DATABASE statement when a database is already open closes the current database before opening the new one. Closing the current database releases any cursor resources that the database server holds, invalidating any cursors that you have declared up to that point. If the user specification was changed through a SET SESSION AUTHORIZATION statement, the original user name is restored when the new database is opened.

If a previous CONNECT statement has established an explicit connection to a database, and that connection is still your current connection, you cannot use the DATABASE statement (nor any SQL statement that creates an implicit connection) until after you use DISCONNECT to close the explicit connection.

The current user (or PUBLIC) must have the Connect privilege on the database that is specified in the DATABASE statement. The current user cannot have the same user name as an existing role in the database.

DATABASE is not a valid statement in multistatement PREPARE operations.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]