ALTER DATABASE

Alter attributes of an existing physical database.

ALTER DATABASE name [ [ WITH ] ALLOW_CONNECTIONS { true | false }  ]
ALTER DATABASE CONNECTION LIMIT number
ALTER DATABASE name RENAME TO new_name
ALTER DATABASE name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALLOW_CONNECTIONS
Specify whether the database accepts user connections: true or false.
CONNECTION LIMIT
Set a limit on the number of concurrent database connections by regular users (superuser connections do not count). Some of these connections may be used up by internal database services.
RENAME TO
Rename a database. You cannot rename the current database.
OWNER TO
Change the owner of a database. See CURRENT_USER and SESSION_USER.
For example, attempt to alter the name of the current database, then switch to another database and retry.
shakespeare=# alter database shakespeare rename to shakes;
ERROR:  current database cannot be renamed
shakespeare=# \c premdb
You are now connected to database "premdb" as user "brumsby".
premdb=# alter database shakespeare rename to shakes;
ALTER DATABASE
Change the owner of the premdb database:
premdb=# alter database premdb owner to bobr;
ALTER DATABASE
Disable connections to the yellowbrick database:
premdb=# alter database yellowbrick allow_connections false;
ALTER DATABASE
premdb=# \c yellowbrick
FATAL:  database "yellowbrick" is not currently accepting connections
Previous connection kept