1ALTER COLLATION(7) PostgreSQL 15.4 Documentation ALTER COLLATION(7)
2
3
4
6 ALTER_COLLATION - change the definition of a collation
7
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
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
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
42 When a collation object is created, the provider-specific version of
43 the collation is recorded in the system catalog. When the collation is
44 used, the current version is checked against the recorded version, and
45 a warning is issued when there is a mismatch, for example:
46
47 WARNING: collation "xx-x-icu" has version mismatch
48 DETAIL: The collation in the database was created using version 1.2.3.4, but the operating system provides version 2.3.4.5.
49 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.
50
51 A change in collation definitions can lead to corrupt indexes and other
52 problems because the database system relies on stored objects having a
53 certain sort order. Generally, this should be avoided, but it can
54 happen in legitimate circumstances, such as when upgrading the
55 operating system to a new major version or 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 collation
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. When using collations provided by ICU, the version information
68 is provided by the ICU library and is available on all platforms.
69
70 Note
71 When using the GNU C library for collations, the C library's
72 version is used as a proxy for the collation version. Many Linux
73 distributions change collation definitions only when upgrading the
74 C library, but this approach is imperfect as maintainers are free
75 to back-port newer collation definitions to older C library
76 releases.
77
78 When using Windows for collations, version information is only
79 available for collations defined with BCP 47 language tags such as
80 en-US.
81
82 For the database default collation, there is an analogous command ALTER
83 DATABASE ... REFRESH COLLATION VERSION.
84
85 The following query can be used to identify all collations in the
86 current database that need to be refreshed and the objects that depend
87 on them:
88
89 SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
90 pg_describe_object(classid, objid, objsubid) AS "Object"
91 FROM pg_depend d JOIN pg_collation c
92 ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
93 WHERE c.collversion <> pg_collation_actual_version(c.oid)
94 ORDER BY 1, 2;
95
97 To rename the collation de_DE to german:
98
99 ALTER COLLATION "de_DE" RENAME TO german;
100
101 To change the owner of the collation en_US to joe:
102
103 ALTER COLLATION "en_US" OWNER TO joe;
104
106 There is no ALTER COLLATION statement in the SQL standard.
107
109 CREATE COLLATION (CREATE_COLLATION(7)), DROP COLLATION
110 (DROP_COLLATION(7))
111
112
113
114PostgreSQL 15.4 2023 ALTER COLLATION(7)