1ALTER DATABASE(7) PostgreSQL 9.2.24 Documentation ALTER DATABASE(7)
2
3
4
6 ALTER_DATABASE - change a database
7
9 ALTER DATABASE name [ [ WITH ] option [ ... ] ]
10
11 where option can be:
12
13 CONNECTION LIMIT connlimit
14
15 ALTER DATABASE name RENAME TO new_name
16
17 ALTER DATABASE name OWNER TO new_owner
18
19 ALTER DATABASE name SET TABLESPACE new_tablespace
20
21 ALTER DATABASE name SET configuration_parameter { TO | = } { value | DEFAULT }
22 ALTER DATABASE name SET configuration_parameter FROM CURRENT
23 ALTER DATABASE name RESET configuration_parameter
24 ALTER DATABASE name RESET ALL
25
27 ALTER DATABASE changes the attributes of a database.
28
29 The first form changes certain per-database settings. (See below for
30 details.) Only the database owner or a superuser can change these
31 settings.
32
33 The second form changes the name of the database. Only the database
34 owner or a superuser can rename a database; non-superuser owners must
35 also have the CREATEDB privilege. The current database cannot be
36 renamed. (Connect to a different database if you need to do that.)
37
38 The third form changes the owner of the database. To alter the owner,
39 you must own the database and also be a direct or indirect member of
40 the new owning role, and you must have the CREATEDB privilege. (Note
41 that superusers have all these privileges automatically.)
42
43 The fourth form changes the default tablespace of the database. Only
44 the database owner or a superuser can do this; you must also have
45 create privilege for the new tablespace. This command physically moves
46 any tables or indexes in the database's old default tablespace to the
47 new tablespace. Note that tables and indexes in non-default tablespaces
48 are not affected.
49
50 The remaining forms change the session default for a run-time
51 configuration variable for a PostgreSQL database. Whenever a new
52 session is subsequently started in that database, the specified value
53 becomes the session default value. The database-specific default
54 overrides whatever setting is present in postgresql.conf or has been
55 received from the postgres command line. Only the database owner or a
56 superuser can change the session defaults for a database. Certain
57 variables cannot be set this way, or can only be set by a superuser.
58
60 name
61 The name of the database whose attributes are to be altered.
62
63 connlimit
64 How many concurrent connections can be made to this database. -1
65 means no limit.
66
67 new_name
68 The new name of the database.
69
70 new_owner
71 The new owner of the database.
72
73 new_tablespace
74 The new default tablespace of the database.
75
76 configuration_parameter, value
77 Set this database's session default for the specified configuration
78 parameter to the given value. If value is DEFAULT or, equivalently,
79 RESET is used, the database-specific setting is removed, so the
80 system-wide default setting will be inherited in new sessions. Use
81 RESET ALL to clear all database-specific settings. SET FROM
82 CURRENT saves the session's current value of the parameter as the
83 database-specific value.
84
85 See SET(7) and Chapter 18, Server Configuration, in the
86 documentation for more information about allowed parameter names
87 and values.
88
90 It is also possible to tie a session default to a specific role rather
91 than to a database; see ALTER ROLE (ALTER_ROLE(7)). Role-specific
92 settings override database-specific ones if there is a conflict.
93
95 To disable index scans by default in the database test:
96
97 ALTER DATABASE test SET enable_indexscan TO off;
98
100 The ALTER DATABASE statement is a PostgreSQL extension.
101
103 CREATE DATABASE (CREATE_DATABASE(7)), DROP DATABASE (DROP_DATABASE(7)),
104 SET(7), CREATE TABLESPACE (CREATE_TABLESPACE(7))
105
106
107
108PostgreSQL 9.2.24 2017-11-06 ALTER DATABASE(7)