RENAME DATABASE statement

Use the RENAME DATABASE statement to change the name of a database. This statement is an extension to the ANSI/ISO standard for SQL.

Syntax

RENAME DATABASE [ owner. ] old_databaseTOnew_database
Element Description Restrictions Syntax
new_database New name that you declare here for old_database Must be unique among database names of the current database server; must not be opened by any user when this statement is issued Database Name
old_database Name that new_database replaces Must exist on current database server, but it cannot be the name of the current database

Cannot be a tenant database.

Database Name
owner Owner of old_database Must be the owner of the database Owner name

Usage

You can rename a database if any of the following is true:
  • You created the database.
  • You have the DBA privilege on the database.
  • The database is not a tenant database. Tenant databases cannot be renamed.
The RENAME DATABASE statement fails with error -9874, however, if the specified database contains any of the following objects:
  • a virtual table
  • a virtual index
  • an R-tree index
  • a DataBlade® that references the current name of the database in a user-defined primary access method or in a user-defined secondary access method.

You can only rename databases of the database server to which you are currently connected.

You cannot rename a database from inside an SPL routine.