1ALTER COLLATION(7)       PostgreSQL 14.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_ROLE | 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, version information is recorded
66       on systems using the GNU C library (most Linux systems), FreeBSD and
67       Windows.
68
69           Note
70           When using the GNU C library for collations, the C library's
71           version is used as a proxy for the collation version. Many Linux
72           distributions change collation definitions only when upgrading the
73           C library, but this approach is imperfect as maintainers are free
74           to back-port newer collation definitions to older C library
75           releases.
76
77           When using Windows for collations, version information is only
78           available for collations defined with BCP 47 language tags such as
79           en-US.
80
81       Currently, there is no version tracking for the database default
82       collation.
83
84       The following query can be used to identify all collations in the
85       current database that need to be refreshed and the objects that depend
86       on them:
87
88           SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
89                  pg_describe_object(classid, objid, objsubid) AS "Object"
90             FROM pg_depend d JOIN pg_collation c
91                  ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
92             WHERE c.collversion <> pg_collation_actual_version(c.oid)
93             ORDER BY 1, 2;
94

EXAMPLES

96       To rename the collation de_DE to german:
97
98           ALTER COLLATION "de_DE" RENAME TO german;
99
100       To change the owner of the collation en_US to joe:
101
102           ALTER COLLATION "en_US" OWNER TO joe;
103

COMPATIBILITY

105       There is no ALTER COLLATION statement in the SQL standard.
106

SEE ALSO

108       CREATE COLLATION (CREATE_COLLATION(7)), DROP COLLATION
109       (DROP_COLLATION(7))
110
111
112
113PostgreSQL 14.3                      2022                   ALTER COLLATION(7)
Impressum