1ALTER COLLATION(7)       PostgreSQL 12.2 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       The following query can be used to identify all collations in the
66       current database that need to be refreshed and the objects that depend
67       on them:
68
69           SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
70                  pg_describe_object(classid, objid, objsubid) AS "Object"
71             FROM pg_depend d JOIN pg_collation c
72                  ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
73             WHERE c.collversion <> pg_collation_actual_version(c.oid)
74             ORDER BY 1, 2;
75
76

EXAMPLES

78       To rename the collation de_DE to german:
79
80           ALTER COLLATION "de_DE" RENAME TO german;
81
82       To change the owner of the collation en_US to joe:
83
84           ALTER COLLATION "en_US" OWNER TO joe;
85

COMPATIBILITY

87       There is no ALTER COLLATION statement in the SQL standard.
88

SEE ALSO

90       CREATE COLLATION (CREATE_COLLATION(7)), DROP COLLATION
91       (DROP_COLLATION(7))
92
93
94
95PostgreSQL 12.2                      2020                   ALTER COLLATION(7)
Impressum