CREATE CONVERSION 中文man頁(yè)面
NAME
CREATE CONVERSION - 定義一個(gè)用戶定義的碼制轉(zhuǎn)換
SYNOPSIS
CREATE [DEFAULT] CONVERSION name FOR source_encoding TO dest_encoding FROM funcname
DESCRIPTION 描述
CREATE CONVERSION 定義一種新的編碼轉(zhuǎn)換。 轉(zhuǎn)換的名字可以用在 convert 函數(shù)內(nèi)部聲明特定的編碼轉(zhuǎn)換。 同樣,標(biāo)記為 DEFAULT 的轉(zhuǎn)換可以用于在前端和后端之間的自動(dòng)編碼轉(zhuǎn)換。 出于這個(gè)原因,我們必須定義兩種轉(zhuǎn)換,從編碼 A 到 B 以及從編碼 B 到 A。
為了可以創(chuàng)建轉(zhuǎn)換,你必須在函數(shù)上有EXECUTE權(quán)限并且有在目標(biāo)模式上的CREATE權(quán)限。
PARAMETERS 參數(shù)
- DEFAULT
- DEFAULT 子句表示這種轉(zhuǎn)換對(duì)于從這種源編碼到目的編碼的情況是缺省的。在一個(gè)模式里每個(gè)編碼對(duì)應(yīng)該只有一個(gè)缺省編碼。
- name
轉(zhuǎn)換的名字。轉(zhuǎn)換名可以用模式修飾。如果沒(méi)有,那么轉(zhuǎn)換就在當(dāng)前模式中定義。轉(zhuǎn)換名在一個(gè)模式里必須***。- source_encoding
源編碼名。- dest_encoding
目的編碼名。- funcname
用于執(zhí)行轉(zhuǎn)換的函數(shù)。這個(gè)函數(shù)名可以用模式名修飾。 如果沒(méi)有,那么將從路徑中找出這個(gè)函數(shù)。
此函數(shù)必須有如下的樣子:conv_proc( integer, -- 源編碼 ID integer, -- 目的編碼 ID cstring, -- 源字串(空結(jié)尾的 C 字串) cstring, -- 目的字串(空結(jié)尾的 C 字串) integer -- 源字串長(zhǎng)度 ) RETURNS void;
NOTES 注意
使用 DROP CONVERSION 刪除用戶定義的轉(zhuǎn)換。
創(chuàng)建轉(zhuǎn)換所需要的權(quán)限可能在未來(lái)的版本中改變。
EXAMPLES 例子
用 myfunc 創(chuàng)建一個(gè)從編碼 UNICODE 到 LATIN1 的轉(zhuǎn)換:
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
COMPATIBILITY 兼容性
CREATE CONVERSION 是 PostgreSQL 的擴(kuò)展。 在 SQL 標(biāo)準(zhǔn)里沒(méi)有CREATE CONVERSION 語(yǔ)句。
SEE ALSO 參見(jiàn)
ALTER CONVERSION [alter_conversion(7)], CREATE FUNCTION [create_function(l)], DROP CONVERSION [drop_conversion(l)]
#p#
NAME
CREATE CONVERSION - define a new conversion
SYNOPSIS
CREATE [DEFAULT] CONVERSION name FOR source_encoding TO dest_encoding FROM funcname
DESCRIPTION
CREATE CONVERSION defines a new encoding conversion. Conversion names may be used in the convert function to specify a particular encoding conversion. Also, conversions that are marked DEFAULT can be used for automatic encoding conversion between client and server. For this purpose, two conversions, from encoding A to B and from encoding B to A, must be defined.
To be able to create a conversion, you must have EXECUTE privilege on the function and CREATE privilege on the destination schema.
PARAMETERS
- DEFAULT
- The DEFAULT clause indicates that this conversion is the default for this particular source to destination encoding. There should be only one default encoding in a schema for the encoding pair.
- name
- The name of the conversion. The conversion name may be schema-qualified. If it is not, the conversion is defined in the current schema. The conversion name must be unique within a schema.
- source_encoding
- The source encoding name.
- dest_encoding
- The destination encoding name.
- funcname
- The function used to perform the conversion. The function name may be schema-qualified. If it is not, the function will be looked up in the path.
The function must have the following signature:
conv_proc( integer, -- source encoding ID integer, -- destination encoding ID cstring, -- source string (null terminated C string) cstring, -- destination string (null terminated C string) integer -- source string length ) RETURNS void;
NOTES
Use DROP CONVERSION to remove user-defined conversions.
The privileges required to create a conversion may be changed in a future release.
EXAMPLES
To create a conversion from encoding UNICODE to LATIN1 using myfunc:
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
COMPATIBILITY
CREATE CONVERSION is a PostgreSQL extension. There is no CREATE CONVERSION statement in the SQL standard.
SEE ALSO
ALTER CONVERSION [alter_conversion(7)], CREATE FUNCTION [create_function(l)], DROP CONVERSION [drop_conversion(l)]