3
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4
<title>CREATE CONVERSION</title>
5
<link rel="stylesheet" href="stylesheet.css" type="text/css">
6
<link rev="made" href="pgsql-docs@postgresql.org">
7
<meta name="generator" content="DocBook XSL Stylesheets V1.64.1">
8
<link rel="home" href="index.html" title="PostgreSQL 8.0.0beta5 Documentation">
9
<link rel="up" href="sql-commands.html" title="SQL Commands">
10
<link rel="previous" href="sql-createconstraint.html" title="CREATE CONSTRAINT TRIGGER">
11
<link rel="next" href="sql-createdatabase.html" title="CREATE DATABASE">
13
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
14
<a name="sql-createconversion"></a><div class="titlepage">
18
<div class="refnamediv">
20
<p>CREATE CONVERSION — define a new conversion</p>
22
<a name="id2670714"></a><div class="refsynopsisdiv">
24
<pre class="synopsis">CREATE [DEFAULT] CONVERSION <i class="replaceable"><tt>name</tt></i>
25
FOR <i class="replaceable"><tt>source_encoding</tt></i> TO <i class="replaceable"><tt>dest_encoding</tt></i> FROM <i class="replaceable"><tt>funcname</tt></i></pre>
27
<div class="refsect1" lang="en">
28
<a name="sql-createconversion-description"></a><h2>Description</h2>
29
<p> <tt class="command">CREATE CONVERSION</tt> defines a new encoding
30
conversion. Conversion names may be used in the <tt class="function">convert</tt> function
31
to specify a particular encoding conversion. Also, conversions that
32
are marked <tt class="literal">DEFAULT</tt> can be used for automatic encoding conversion between
33
client and server. For this purpose, two conversions, from encoding A to
34
B <span class="emphasis"><em>and</em></span> from encoding B to A, must be defined.
36
<p> To be able to create a conversion, you must have <tt class="literal">EXECUTE</tt> privilege
37
on the function and <tt class="literal">CREATE</tt> privilege on the destination schema.
40
<div class="refsect1" lang="en">
41
<a name="id2670798"></a><h2>Parameters</h2>
42
<div class="variablelist"><dl>
43
<dt><span class="term"><tt class="literal">DEFAULT</tt></span></dt>
44
<dd><p> The <tt class="literal">DEFAULT</tt> clause indicates that this conversion
45
is the default for this particular source to destination
46
encoding. There should be only one default encoding in a schema
47
for the encoding pair.
49
<dt><span class="term"><i class="replaceable"><tt>name</tt></i></span></dt>
50
<dd><p> The name of the conversion. The conversion name may be
51
schema-qualified. If it is not, the conversion is defined in the
52
current schema. The conversion name must be unique within a
55
<dt><span class="term"><i class="replaceable"><tt>source_encoding</tt></i></span></dt>
56
<dd><p> The source encoding name.
58
<dt><span class="term"><i class="replaceable"><tt>dest_encoding</tt></i></span></dt>
59
<dd><p> The destination encoding name.
61
<dt><span class="term"><i class="replaceable"><tt>funcname</tt></i></span></dt>
63
<p> The function used to perform the conversion. The function name may
64
be schema-qualified. If it is not, the function will be looked
67
<p> The function must have the following signature:
70
<pre class="programlisting">conv_proc(
71
integer, -- source encoding ID
72
integer, -- destination encoding ID
73
cstring, -- source string (null terminated C string)
74
cstring, -- destination string (null terminated C string)
75
integer -- source string length
82
<div class="refsect1" lang="en">
83
<a name="sql-createconversion-notes"></a><h2>Notes</h2>
84
<p> Use <tt class="command">DROP CONVERSION</tt> to remove user-defined conversions.
86
<p> The privileges required to create a conversion may be changed in a future
90
<div class="refsect1" lang="en">
91
<a name="sql-createconversion-examples"></a><h2>Examples</h2>
92
<p> To create a conversion from encoding <tt class="literal">UNICODE</tt> to
93
<tt class="literal">LATIN1</tt> using <tt class="function">myfunc</tt>:
95
<pre class="programlisting">CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;</pre>
99
<div class="refsect1" lang="en">
100
<a name="sql-createconversion-compat"></a><h2>Compatibility</h2>
101
<p> <tt class="command">CREATE CONVERSION</tt>
102
is a <span class="productname">PostgreSQL</span> extension.
103
There is no <tt class="command">CREATE CONVERSION</tt>
104
statement in the SQL standard.
107
<div class="refsect1" lang="en">
108
<a name="sql-createconversion-seealso"></a><h2>See Also</h2>
109
<span class="simplelist"><a href="sql-alterconversion.html">ALTER CONVERSION</a>, <a href="sql-createfunction.html">CREATE FUNCTION</a>, <a href="sql-dropconversion.html">DROP CONVERSION</a></span>