gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

109 行
9.7KB

  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>CREATE 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 V1.79.1" /><link rel="prev" href="sql-createcast.html" title="CREATE CAST" /><link rel="next" href="sql-createconversion.html" title="CREATE CONVERSION" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">CREATE COLLATION</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-createcast.html" title="CREATE CAST">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 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-createconversion.html" title="CREATE CONVERSION">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SQL-CREATECOLLATION"><div class="titlepage"></div><a id="id-1.9.3.59.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">CREATE COLLATION</span></h2><p>CREATE COLLATION — define a new collation</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. CREATE COLLATION [ IF NOT EXISTS ] <em class="replaceable"><code>name</code></em> (
  4. [ LOCALE = <em class="replaceable"><code>locale</code></em>, ]
  5. [ LC_COLLATE = <em class="replaceable"><code>lc_collate</code></em>, ]
  6. [ LC_CTYPE = <em class="replaceable"><code>lc_ctype</code></em>, ]
  7. [ PROVIDER = <em class="replaceable"><code>provider</code></em>, ]
  8. [ DETERMINISTIC = <em class="replaceable"><code>boolean</code></em>, ]
  9. [ VERSION = <em class="replaceable"><code>version</code></em> ]
  10. )
  11. CREATE COLLATION [ IF NOT EXISTS ] <em class="replaceable"><code>name</code></em> FROM <em class="replaceable"><code>existing_collation</code></em>
  12. </pre></div><div class="refsect1" id="SQL-CREATECOLLATION-DESCRIPTION"><h2>Description</h2><p>
  13. <code class="command">CREATE COLLATION</code> defines a new collation using
  14. the specified operating system locale settings,
  15. or by copying an existing collation.
  16. </p><p>
  17. To be able to create a collation, you must
  18. have <code class="literal">CREATE</code> privilege on the destination schema.
  19. </p></div><div class="refsect1" id="id-1.9.3.59.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">IF NOT EXISTS</code></span></dt><dd><p>
  20. Do not throw an error if a collation with the same name already exists.
  21. A notice is issued in this case. Note that there is no guarantee that
  22. the existing collation is anything like the one that would have been created.
  23. </p></dd><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
  24. The name of the collation. The collation name can be
  25. schema-qualified. If it is not, the collation is defined in the
  26. current schema. The collation name must be unique within that
  27. schema. (The system catalogs can contain collations with the
  28. same name for other encodings, but these are ignored if the
  29. database encoding does not match.)
  30. </p></dd><dt><span class="term"><em class="replaceable"><code>locale</code></em></span></dt><dd><p>
  31. This is a shortcut for setting <code class="symbol">LC_COLLATE</code>
  32. and <code class="symbol">LC_CTYPE</code> at once. If you specify this,
  33. you cannot specify either of those parameters.
  34. </p></dd><dt><span class="term"><em class="replaceable"><code>lc_collate</code></em></span></dt><dd><p>
  35. Use the specified operating system locale for
  36. the <code class="symbol">LC_COLLATE</code> locale category.
  37. </p></dd><dt><span class="term"><em class="replaceable"><code>lc_ctype</code></em></span></dt><dd><p>
  38. Use the specified operating system locale for
  39. the <code class="symbol">LC_CTYPE</code> locale category.
  40. </p></dd><dt><span class="term"><em class="replaceable"><code>provider</code></em></span></dt><dd><p>
  41. Specifies the provider to use for locale services associated with this
  42. collation. Possible values
  43. are: <code class="literal">icu</code>,<a id="id-1.9.3.59.6.2.6.2.1.2" class="indexterm"></a>
  44. <code class="literal">libc</code>.
  45. <code class="literal">libc</code> is the default.
  46. The available choices depend on the operating system and build options.
  47. </p></dd><dt><span class="term"><code class="literal">DETERMINISTIC</code></span></dt><dd><p>
  48. Specifies whether the collation should use deterministic comparisons.
  49. The default is true. A deterministic comparison considers strings that
  50. are not byte-wise equal to be unequal even if they are considered
  51. logically equal by the comparison. PostgreSQL breaks ties using a
  52. byte-wise comparison. Comparison that is not deterministic can make the
  53. collation be, say, case- or accent-insensitive. For that, you need to
  54. choose an appropriate <code class="literal">LC_COLLATE</code> setting
  55. <span class="emphasis"><em>and</em></span> set the collation to not deterministic here.
  56. </p><p>
  57. Nondeterministic collations are only supported with the ICU provider.
  58. </p></dd><dt><span class="term"><em class="replaceable"><code>version</code></em></span></dt><dd><p>
  59. Specifies the version string to store with the collation. Normally,
  60. this should be omitted, which will cause the version to be computed
  61. from the actual version of the collation as provided by the operating
  62. system. This option is intended to be used
  63. by <code class="command">pg_upgrade</code> for copying the version from an
  64. existing installation.
  65. </p><p>
  66. See also <a class="xref" href="sql-altercollation.html" title="ALTER COLLATION"><span class="refentrytitle">ALTER COLLATION</span></a> for how to handle
  67. collation version mismatches.
  68. </p></dd><dt><span class="term"><em class="replaceable"><code>existing_collation</code></em></span></dt><dd><p>
  69. The name of an existing collation to copy. The new collation
  70. will have the same properties as the existing one, but it
  71. will be an independent object.
  72. </p></dd></dl></div></div><div class="refsect1" id="SQL-CREATECOLLATION-NOTES"><h2>Notes</h2><p>
  73. <code class="command">CREATE COLLATION</code> takes a <code class="literal">SHARE ROW
  74. EXCLUSIVE</code> lock, which is self-conflicting, on the
  75. <code class="structname">pg_collation</code> system catalog, so only one
  76. <code class="command">CREATE COLLATION</code> command can run at a time.
  77. </p><p>
  78. Use <code class="command">DROP COLLATION</code> to remove user-defined collations.
  79. </p><p>
  80. See <a class="xref" href="collation.html#COLLATION-CREATE" title="23.2.2.3. Creating New Collation Objects">Section 23.2.2.3</a> for more information on how to create collations.
  81. </p><p>
  82. When using the <code class="literal">libc</code> collation provider, the locale must
  83. be applicable to the current database encoding.
  84. See <a class="xref" href="sql-createdatabase.html" title="CREATE DATABASE"><span class="refentrytitle">CREATE DATABASE</span></a> for the precise rules.
  85. </p></div><div class="refsect1" id="SQL-CREATECOLLATION-EXAMPLES"><h2>Examples</h2><p>
  86. To create a collation from the operating system locale
  87. <code class="literal">fr_FR.utf8</code>
  88. (assuming the current database encoding is <code class="literal">UTF8</code>):
  89. </p><pre class="programlisting">
  90. CREATE COLLATION french (locale = 'fr_FR.utf8');
  91. </pre><p>
  92. </p><p>
  93. To create a collation using the ICU provider using German phone book sort order:
  94. </p><pre class="programlisting">
  95. CREATE COLLATION german_phonebook (provider = icu, locale = 'de-u-co-phonebk');
  96. </pre><p>
  97. </p><p>
  98. To create a collation from an existing collation:
  99. </p><pre class="programlisting">
  100. CREATE COLLATION german FROM "de_DE";
  101. </pre><p>
  102. This can be convenient to be able to use operating-system-independent
  103. collation names in applications.
  104. </p></div><div class="refsect1" id="SQL-CREATECOLLATION-COMPAT"><h2>Compatibility</h2><p>
  105. There is a <code class="command">CREATE COLLATION</code> statement in the SQL
  106. standard, but it is limited to copying an existing collation. The
  107. syntax to create a new collation is
  108. a <span class="productname">PostgreSQL</span> extension.
  109. </p></div><div class="refsect1" id="SQL-CREATECOLLATION-SEEALSO"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-altercollation.html" title="ALTER COLLATION"><span class="refentrytitle">ALTER 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-createcast.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-createconversion.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">CREATE CAST </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> CREATE CONVERSION</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1