4 ALTER COLLATION — change the definition of a collation
8 ALTER COLLATION name REFRESH VERSION
10 ALTER COLLATION name RENAME TO new_name
11 ALTER COLLATION name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSIO
13 ALTER COLLATION name SET SCHEMA new_schema
17 ALTER COLLATION changes the definition of a collation.
19 You must own the collation to use ALTER COLLATION. To alter the owner,
20 you must be able to SET ROLE to the new owning role, and that role must
21 have CREATE privilege on the collation's schema. (These restrictions
22 enforce that altering the owner doesn't do anything you couldn't do by
23 dropping and recreating the collation. However, a superuser can alter
24 ownership of any collation anyway.)
29 The name (optionally schema-qualified) of an existing collation.
32 The new name of the collation.
35 The new owner of the collation.
38 The new schema for the collation.
41 Update the collation's version. See Notes below.
45 When a collation object is created, the provider-specific version of
46 the collation is recorded in the system catalog. When the collation is
47 used, the current version is checked against the recorded version, and
48 a warning is issued when there is a mismatch, for example:
49 WARNING: collation "xx-x-icu" has version mismatch
50 DETAIL: The collation in the database was created using version 1.2.3.4, but th
51 e operating system provides version 2.3.4.5.
52 HINT: Rebuild all objects affected by this collation and run ALTER COLLATION pg
53 _catalog."xx-x-icu" REFRESH VERSION, or build PostgreSQL with the right library
56 A change in collation definitions can lead to corrupt indexes and other
57 problems because the database system relies on stored objects having a
58 certain sort order. Generally, this should be avoided, but it can
59 happen in legitimate circumstances, such as when upgrading the
60 operating system to a new major version or when using pg_upgrade to
61 upgrade to server binaries linked with a newer version of ICU. When
62 this happens, all objects depending on the collation should be rebuilt,
63 for example, using REINDEX. When that is done, the collation version
64 can be refreshed using the command ALTER COLLATION ... REFRESH VERSION.
65 This will update the system catalog to record the current collation
66 version and will make the warning go away. Note that this does not
67 actually check whether all affected objects have been rebuilt
70 When using collations provided by libc, version information is recorded
71 on systems using the GNU C library (most Linux systems), FreeBSD and
72 Windows. When using collations provided by ICU, the version information
73 is provided by the ICU library and is available on all platforms.
77 When using the GNU C library for collations, the C library's version is
78 used as a proxy for the collation version. Many Linux distributions
79 change collation definitions only when upgrading the C library, but
80 this approach is imperfect as maintainers are free to back-port newer
81 collation definitions to older C library releases.
83 When using Windows for collations, version information is only
84 available for collations defined with BCP 47 language tags such as
87 For the database default collation, there is an analogous command ALTER
88 DATABASE ... REFRESH COLLATION VERSION.
90 The following query can be used to identify all collations in the
91 current database that need to be refreshed and the objects that depend
93 SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
94 pg_describe_object(classid, objid, objsubid) AS "Object"
95 FROM pg_depend d JOIN pg_collation c
96 ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
97 WHERE c.collversion <> pg_collation_actual_version(c.oid)
102 To rename the collation de_DE to german:
103 ALTER COLLATION "de_DE" RENAME TO german;
105 To change the owner of the collation en_US to joe:
106 ALTER COLLATION "en_US" OWNER TO joe;
110 There is no ALTER COLLATION statement in the SQL standard.
114 CREATE COLLATION, DROP COLLATION