1ALTER DATABASE()                 SQL Commands                 ALTER DATABASE()
2
3
4

NAME

6       ALTER DATABASE - change a database
7
8

SYNOPSIS

10       ALTER DATABASE name [ [ WITH ] option [ ... ] ]
11
12       where option can be:
13
14           CONNECTION LIMIT connlimit
15
16       ALTER DATABASE name SET parameter { TO | = } { value | DEFAULT }
17       ALTER DATABASE name RESET parameter
18
19       ALTER DATABASE name RENAME TO newname
20
21       ALTER DATABASE name OWNER TO new_owner
22
23

DESCRIPTION

25       ALTER DATABASE changes the attributes of a database.
26
27       The  first  form  changes certain per-database settings. (See below for
28       details.) Only the database owner or a superuser can change these  set‐
29       tings.
30
31       The  second  and  third forms change the session default for a run-time
32       configuration variable for a PostgreSQL database. Whenever a  new  ses‐
33       sion  is  subsequently  started  in  that database, the specified value
34       becomes the session default value.  The database-specific default over‐
35       rides  whatever  setting  is  present  in  postgresql.conf  or has been
36       received from the postgres command line. Only the database owner  or  a
37       superuser can change the session defaults for a database. Certain vari‐
38       ables cannot be set this way, or can only be set by a superuser.
39
40       The fourth form changes the name of the  database.  Only  the  database
41       owner  or  a superuser can rename a database; non-superuser owners must
42       also have the  CREATEDB  privilege.  The  current  database  cannot  be
43       renamed. (Connect to a different database if you need to do that.)
44
45       The  fifth form changes the owner of the database.  To alter the owner,
46       you must own the database and also be a direct or  indirect  member  of
47       the  new  owning role, and you must have the CREATEDB privilege.  (Note
48       that superusers have all these privileges automatically.)
49

PARAMETERS

51       name   The name of the database whose attributes are to be altered.
52
53       connlimit
54              How many concurrent connections can be made to this database. -1
55              means no limit.
56
57       parameter
58
59       value  Set this database's session default for the specified configura‐
60              tion parameter to the given  value.  If  value  is  DEFAULT  or,
61              equivalently,  RESET  is  used, the database-specific setting is
62              removed, so the system-wide default setting will be inherited in
63              new  sessions. Use RESET ALL to clear all database-specific set‐
64              tings.
65
66              See SET [set(7)] and in the documentation for  more  information
67              about allowed parameter names and values.
68
69       newname
70              The new name of the database.
71
72       new_owner
73              The new owner of the database.
74

NOTES

76       It  is also possible to tie a session default to a specific user rather
77       than to a database; see ALTER USER [alter_user(7)].  User-specific set‐
78       tings override database-specific ones if there is a conflict.
79

EXAMPLES

81       To disable index scans by default in the database test:
82
83       ALTER DATABASE test SET enable_indexscan TO off;
84
85

COMPATIBILITY

87       The ALTER DATABASE statement is a PostgreSQL extension.
88

SEE ALSO

90       CREATE DATABASE [create_database(7)], DROP DATABASE [drop_database(l)],
91       SET [set(l)]
92
93
94
95SQL - Language Statements         2008-06-08                  ALTER DATABASE()
Impressum