ALTER DATABASE

Function

This command is used to modify the attributes of a database, including the database name, owner, maximum number of connections, and object isolation attribute.

Important Notes

Syntax

Parameter Description

  • Modifies the default tablespace of a database by moving all the tables or indexes from the old tablespace to the new one. This operation does not affect the tables or indexes in other non-default tablespaces.
  • The modified database session parameter values will take effect in the next session.

Examples

Modify the number of connections of the music database.

1
ALTER DATABASE music CONNECTION LIMIT= 10;

Change the name of the music database to music1.

1
ALTER DATABASE music RENAME TO music1;

Change the owner of the music1 database.

1
ALTER DATABASE music1 OWNER TO tom;

Modify the tablespace of the music1 database.

1
ALTER DATABASE music1 SET TABLESPACE PG_DEFAULT;

Disable the default index scan on the music1 database.

1
ALTER DATABASE music1 SET enable_indexscan TO off;

Reset the enable_indexscan parameter of the music1 database.

1
ALTER DATABASE music1 RESET enable_indexscan;

Links

CREATE DATABASE, DROP DATABASE