Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

ALTER DATABASE

Changes the attributes of a database.

Syntax

Copy
ALTER DATABASE database_name | RENAME TO new_name | OWNER TO new_owner | CONNECTION LIMIT { limit | UNLIMITED } ]

Parameters

database_name

Name of the database to alter. Typically, you alter a database that you are not currently connected to; in any case, the changes take effect only in subsequent sessions. You can change the owner of the current database, but you cannot rename it:

Copy
alter database tickit rename to newtickit; ERROR: current database may not be renamed
RENAME TO

Renames the specified database. For more information about valid names, see Names and Identifiers. You cannot rename the dev, padb_harvest, template0, or template1 databases, and you cannot rename the current database. Only the database owner or a superuser can rename a database; non-superuser owners must also have the CREATEDB privilege.

new_name

New database name.

OWNER TO

Changes the owner of the specified database. You can change the owner of the current database or some other database. Only a superuser can change the owner.

new_owner

New database owner. The new owner must be an existing database user with write privileges. See GRANT for more information about user privileges.

CONNECTION LIMIT { limit | UNLIMITED }

The maximum number of database connections users are permitted to have open concurrently. The limit is not enforced for super users. Use the UNLIMITED keyword to permit the maximum number of concurrent connections. The limit of concurrent connections for each cluster is 500. A limit on the number of connections for each user might also apply. For more information, see CREATE USER. The default is UNLIMITED. To view current connections, query the STV_SESSIONS system view.

Note

If both user and database connection limits apply, an unused connection slot must be available that is within both limits when a user attempts to connect.

Usage Notes

ALTER DATABASE commands apply to subsequent sessions not current sessions. You need to reconnect to the altered database to see the effect of the change.

Examples

The following example renames a database named TICKIT_SANDBOX to TICKIT_TEST:

Copy
alter database tickit_sandbox rename to tickit_test;

The following example changes the owner of the TICKIT database (the current database) to DWUSER:

Copy
alter database tickit owner to dwuser;