3 <refentry id=
"SQL-CREATECONVERSION">
5 <refentrytitle id=
"SQL-CREATECONVERSION-TITLE">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>funcname
</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>funcname
</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
123 <refsect1 id=
"sql-createconversion-notes">
127 Use
<command>DROP CONVERSION
</command> to remove user-defined conversions.
131 The privileges required to create a conversion might be changed in a future
136 <refsect1 id=
"sql-createconversion-examples">
137 <title>Examples
</title>
140 To create a conversion from encoding
<literal>UTF8
</literal> to
141 <literal>LATIN1
</literal> using
<function>myfunc<
/>:
143 CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;
149 <refsect1 id=
"sql-createconversion-compat">
150 <title>Compatibility
</title>
153 <command>CREATE CONVERSION
</command>
154 is a
<productname>PostgreSQL
</productname> extension.
155 There is no
<command>CREATE CONVERSION
</command>
156 statement in the SQL standard.
161 <refsect1 id=
"sql-createconversion-seealso">
162 <title>See Also
</title>
164 <simplelist type=
"inline">
165 <member><xref linkend=
"sql-alterconversion" endterm=
"sql-alterconversion-title"></member>
166 <member><xref linkend=
"sql-createfunction" endterm=
"sql-createfunction-title"></member>
167 <member><xref linkend=
"sql-dropconversion" endterm=
"sql-dropconversion-title"></member>