1 <!-- doc/src/sgml/ref/create_conversion.sgml -->
3 <refentry id="SQL-CREATECONVERSION">
5 <refentrytitle>CREATE CONVERSION</refentrytitle>
6 <manvolnum>7</manvolnum>
7 <refmiscinfo>SQL - Language Statements</refmiscinfo>
11 <refname>CREATE CONVERSION</refname>
12 <refpurpose>define a new encoding conversion</refpurpose>
15 <indexterm zone="sql-createconversion">
16 <primary>CREATE CONVERSION</primary>
21 CREATE [ DEFAULT ] CONVERSION <replaceable>name</replaceable>
22 FOR <replaceable>source_encoding</replaceable> TO <replaceable>dest_encoding</replaceable> FROM <replaceable>function_name</replaceable>
26 <refsect1 id="sql-createconversion-description">
27 <title>Description</title>
30 <command>CREATE CONVERSION</command> defines a new conversion between
31 character set encodings. Also, conversions that
32 are marked <literal>DEFAULT</> can be used for automatic encoding
34 client and server. For this purpose, two conversions, from encoding A to
35 B <emphasis>and</emphasis> from encoding B to A, must be defined.
39 To be able to create a conversion, you must have <literal>EXECUTE</literal> privilege
40 on the function and <literal>CREATE</literal> privilege on the destination schema.
46 <title>Parameters</title>
50 <term><literal>DEFAULT</literal></term>
54 The <literal>DEFAULT</> clause indicates that this conversion
55 is the default for this particular source to destination
56 encoding. There should be only one default encoding in a schema
57 for the encoding pair.
63 <term><replaceable>name</replaceable></term>
67 The name of the conversion. The conversion name can be
68 schema-qualified. If it is not, the conversion is defined in the
69 current schema. The conversion name must be unique within a
76 <term><replaceable>source_encoding</replaceable></term>
80 The source encoding name.
86 <term><replaceable>dest_encoding</replaceable></term>
90 The destination encoding name.
96 <term><replaceable>function_name</replaceable></term>
100 The function used to perform the conversion. The function name can
101 be schema-qualified. If it is not, the function will be looked
106 The function must have the following signature:
110 integer, -- source encoding ID
111 integer, -- destination encoding ID
112 cstring, -- source string (null terminated C string)
113 internal, -- destination (fill with a null terminated C string)
114 integer -- source string length
116 </programlisting></para>
122 <refsect1 id="sql-createconversion-notes">
126 Use <command>DROP CONVERSION</command> to remove user-defined conversions.
130 The privileges required to create a conversion might be changed in a future
135 <refsect1 id="sql-createconversion-examples">
136 <title>Examples</title>
139 To create a conversion from encoding <literal>UTF8</literal> to
140 <literal>LATIN1</literal> using <function>myfunc</>:
142 CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;
143 </programlisting></para>
147 <refsect1 id="sql-createconversion-compat">
148 <title>Compatibility</title>
151 <command>CREATE CONVERSION</command>
152 is a <productname>PostgreSQL</productname> extension.
153 There is no <command>CREATE CONVERSION</command>
154 statement in the SQL standard, but a <command>CREATE TRANSLATION</command>
155 statement that is very similar in purpose and syntax.
160 <refsect1 id="sql-createconversion-seealso">
161 <title>See Also</title>
163 <simplelist type="inline">
164 <member><xref linkend="sql-alterconversion"></member>
165 <member><xref linkend="sql-createfunction"></member>
166 <member><xref linkend="sql-dropconversion"></member>