1ALTER COLLATION(7)       PostgreSQL 13.3 Documentation      ALTER COLLATION(7)
2
3
4

NAME

6       ALTER_COLLATION - change the definition of a collation
7

SYNOPSIS

9       ALTER COLLATION name REFRESH VERSION
10
11       ALTER COLLATION name RENAME TO new_name
12       ALTER COLLATION name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
13       ALTER COLLATION name SET SCHEMA new_schema
14

DESCRIPTION

16       ALTER COLLATION changes the definition of a collation.
17
18       You must own the collation to use ALTER COLLATION. To alter the owner,
19       you must also be a direct or indirect member of the new owning role,
20       and that role must have CREATE privilege on the collation's schema.
21       (These restrictions enforce that altering the owner doesn't do anything
22       you couldn't do by dropping and recreating the collation. However, a
23       superuser can alter ownership of any collation anyway.)
24

PARAMETERS

26       name
27           The name (optionally schema-qualified) of an existing collation.
28
29       new_name
30           The new name of the collation.
31
32       new_owner
33           The new owner of the collation.
34
35       new_schema
36           The new schema for the collation.
37
38       REFRESH VERSION
39           Update the collation's version. See Notes below.
40

NOTES

42       When using collations provided by the ICU library, the ICU-specific
43       version of the collator is recorded in the system catalog when the
44       collation object is created. When the collation is used, the current
45       version is checked against the recorded version, and a warning is
46       issued when there is a mismatch, for example:
47
48           WARNING:  collation "xx-x-icu" has version mismatch
49           DETAIL:  The collation in the database was created using version 1.2.3.4, but the operating system provides version 2.3.4.5.
50           HINT:  Rebuild all objects affected by this collation and run ALTER COLLATION pg_catalog."xx-x-icu" REFRESH VERSION, or build PostgreSQL with the right library version.
51
52       A change in collation definitions can lead to corrupt indexes and other
53       problems because the database system relies on stored objects having a
54       certain sort order. Generally, this should be avoided, but it can
55       happen in legitimate circumstances, such as when using pg_upgrade to
56       upgrade to server binaries linked with a newer version of ICU. When
57       this happens, all objects depending on the collation should be rebuilt,
58       for example, using REINDEX. When that is done, the collation version
59       can be refreshed using the command ALTER COLLATION ... REFRESH VERSION.
60       This will update the system catalog to record the current collator
61       version and will make the warning go away. Note that this does not
62       actually check whether all affected objects have been rebuilt
63       correctly.
64
65       When using collations provided by libc and PostgreSQL was built with
66       the GNU C library, the C library's version is used as a collation
67       version. Since collation definitions typically change only with GNU C
68       library releases, this provides some defense against corruption, but it
69       is not completely reliable.
70
71       Currently, there is no version tracking for the database default
72       collation.
73
74       The following query can be used to identify all collations in the
75       current database that need to be refreshed and the objects that depend
76       on them:
77
78           SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
79                  pg_describe_object(classid, objid, objsubid) AS "Object"
80             FROM pg_depend d JOIN pg_collation c
81                  ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
82             WHERE c.collversion <> pg_collation_actual_version(c.oid)
83             ORDER BY 1, 2;
84

EXAMPLES

86       To rename the collation de_DE to german:
87
88           ALTER COLLATION "de_DE" RENAME TO german;
89
90       To change the owner of the collation en_US to joe:
91
92           ALTER COLLATION "en_US" OWNER TO joe;
93

COMPATIBILITY

95       There is no ALTER COLLATION statement in the SQL standard.
96

SEE ALSO

98       CREATE COLLATION (CREATE_COLLATION(7)), DROP COLLATION
99       (DROP_COLLATION(7))
100
101
102
103PostgreSQL 13.3                      2021                   ALTER COLLATION(7)
Impressum