]> begriffs open source - ai-pg/blob - full-docs/html/sql-altercollation.html
Include latest toc output
[ai-pg] / full-docs / html / sql-altercollation.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ALTER COLLATION</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-alteraggregate.html" title="ALTER AGGREGATE" /><link rel="next" href="sql-alterconversion.html" title="ALTER CONVERSION" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">ALTER COLLATION</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-alteraggregate.html" title="ALTER AGGREGATE">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-alterconversion.html" title="ALTER CONVERSION">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-ALTERCOLLATION"><div class="titlepage"></div><a id="id-1.9.3.5.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">ALTER COLLATION</span></h2><p>ALTER COLLATION — change the definition of a collation</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
3 ALTER COLLATION <em class="replaceable"><code>name</code></em> REFRESH VERSION
4
5 ALTER COLLATION <em class="replaceable"><code>name</code></em> RENAME TO <em class="replaceable"><code>new_name</code></em>
6 ALTER COLLATION <em class="replaceable"><code>name</code></em> OWNER TO { <em class="replaceable"><code>new_owner</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
7 ALTER COLLATION <em class="replaceable"><code>name</code></em> SET SCHEMA <em class="replaceable"><code>new_schema</code></em>
8 </pre></div><div class="refsect1" id="id-1.9.3.5.5"><h2>Description</h2><p>
9    <code class="command">ALTER COLLATION</code> changes the definition of a
10    collation.
11   </p><p>
12    You must own the collation to use <code class="command">ALTER COLLATION</code>.
13    To alter the owner, you must be able to <code class="literal">SET ROLE</code> to the
14    new owning role, and that role must have <code class="literal">CREATE</code>
15    privilege on the collation's schema.
16    (These restrictions enforce that altering the
17    owner doesn't do anything you couldn't do by dropping and recreating the
18    collation. However, a superuser can alter ownership of any collation
19    anyway.)
20   </p></div><div class="refsect1" id="id-1.9.3.5.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
21       The name (optionally schema-qualified) of an existing collation.
22      </p></dd><dt><span class="term"><em class="replaceable"><code>new_name</code></em></span></dt><dd><p>
23       The new name of the collation.
24      </p></dd><dt><span class="term"><em class="replaceable"><code>new_owner</code></em></span></dt><dd><p>
25       The new owner of the collation.
26      </p></dd><dt><span class="term"><em class="replaceable"><code>new_schema</code></em></span></dt><dd><p>
27       The new schema for the collation.
28      </p></dd><dt><span class="term"><code class="literal">REFRESH VERSION</code></span></dt><dd><p>
29       Update the collation's version.
30       See <a class="xref" href="sql-altercollation.html#SQL-ALTERCOLLATION-NOTES" title="Notes">Notes</a> below.
31      </p></dd></dl></div></div><div class="refsect1" id="SQL-ALTERCOLLATION-NOTES"><h2>Notes</h2><p>
32    When a collation object is created, the provider-specific version of the
33    collation is recorded in the system catalog.  When the collation is used,
34    the current version is
35    checked against the recorded version, and a warning is issued when there is
36    a mismatch, for example:
37 </p><pre class="screen">
38 WARNING:  collation "xx-x-icu" has version mismatch
39 DETAIL:  The collation in the database was created using version 1.2.3.4, but the operating system provides version 2.3.4.5.
40 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.
41 </pre><p>
42    A change in collation definitions can lead to corrupt indexes and other
43    problems because the database system relies on stored objects having a
44    certain sort order.  Generally, this should be avoided, but it can happen
45    in legitimate circumstances, such as when upgrading the operating system
46    to a new major version or when
47    using <code class="command">pg_upgrade</code> to upgrade to server binaries linked
48    with a newer version of ICU.  When this happens, all objects depending on
49    the collation should be rebuilt, for example,
50    using <code class="command">REINDEX</code>.  When that is done, the collation version
51    can be refreshed using the command <code class="literal">ALTER COLLATION ... REFRESH
52    VERSION</code>.  This will update the system catalog to record the
53    current collation version and will make the warning go away.  Note that this
54    does not actually check whether all affected objects have been rebuilt
55    correctly.
56   </p><p>
57    When using collations provided by <code class="literal">libc</code>, version
58    information is recorded on systems using the GNU C library (most Linux
59    systems), FreeBSD and Windows.  When using collations provided by ICU, the
60    version information is provided by the ICU library and is available on all
61    platforms.
62   </p><div class="note"><h3 class="title">Note</h3><p>
63     When using the GNU C library for collations, the C library's version
64     is used as a proxy for the collation version.  Many Linux distributions
65     change collation definitions only when upgrading the C library, but this
66     approach is imperfect as maintainers are free to back-port newer
67     collation definitions to older C library releases.
68    </p><p>
69     When using Windows for collations, version information is only available
70     for collations defined with BCP 47 language tags such as
71     <code class="literal">en-US</code>.
72    </p></div><p>
73    For the database default collation, there is an analogous command
74    <code class="literal">ALTER DATABASE ... REFRESH COLLATION VERSION</code>.
75   </p><p>
76    The following query can be used to identify all collations in the current
77    database that need to be refreshed and the objects that depend on them:
78 </p><pre class="programlisting">
79 SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
80        pg_describe_object(classid, objid, objsubid) AS "Object"
81   FROM pg_depend d JOIN pg_collation c
82        ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
83   WHERE c.collversion &lt;&gt; pg_collation_actual_version(c.oid)
84   ORDER BY 1, 2;
85 </pre></div><div class="refsect1" id="id-1.9.3.5.8"><h2>Examples</h2><p>
86    To rename the collation <code class="literal">de_DE</code> to
87    <code class="literal">german</code>:
88 </p><pre class="programlisting">
89 ALTER COLLATION "de_DE" RENAME TO german;
90 </pre><p>
91   </p><p>
92    To change the owner of the collation <code class="literal">en_US</code> to
93    <code class="literal">joe</code>:
94 </p><pre class="programlisting">
95 ALTER COLLATION "en_US" OWNER TO joe;
96 </pre></div><div class="refsect1" id="id-1.9.3.5.9"><h2>Compatibility</h2><p>
97    There is no <code class="command">ALTER COLLATION</code> statement in the SQL
98    standard.
99   </p></div><div class="refsect1" id="id-1.9.3.5.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-createcollation.html" title="CREATE COLLATION"><span class="refentrytitle">CREATE COLLATION</span></a>, <a class="xref" href="sql-dropcollation.html" title="DROP COLLATION"><span class="refentrytitle">DROP COLLATION</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-alteraggregate.html" title="ALTER AGGREGATE">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-alterconversion.html" title="ALTER CONVERSION">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ALTER AGGREGATE </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> ALTER CONVERSION</td></tr></table></div></body></html>