CREATE CONVERSION - 定義一個用戶定義的碼制轉換
SYNOPSISCREATE [DEFAULT] CONVERSION name FOR source_encoding TO dest_encoding FROM funcname
DESCRIPTION 描述CREATE CONVERSION 定義一種新的編碼轉換。 轉換的名字可以用在 convert 函數內部聲明特定的編碼轉換。 同樣,標記為 DEFAULT 的轉換可以用於在前端和後端之間的自動編碼轉換。 出於這個原因,我們必須定義兩種轉換,從編碼 A 到 B 以及從編碼 B 到 A。
為了可以創建轉換,你必須在函數上有EXECUTE權限並且有在目標模式上的CREATE權限。
轉換的名字。轉換名可以用模式修飾。如果沒有,那麼轉換就在當前模式中定義。轉換名在一個模式裡必須唯一。 source_encoding
源編碼名。 dest_encoding
目的編碼名。 funcname
用於執行轉換的函數。這個函數名可以用模式名修飾。 如果沒有,那麼將從路徑中找出這個函數。
此函數必須有如下的樣子:
conv_proc( integer, -- 源編碼 ID integer, -- 目的編碼 ID cstring, -- 源字串(空結尾的 C 字串) cstring, -- 目的字串(空結尾的 C 字串) integer -- 源字串長度) RETURNS void;
NOTES 注意
使用 DROP CONVERSION 刪除用戶定義的轉換。
創建轉換所需要的權限可能在未來的版本中改變。
用 myfunc 創建一個從編碼 UNICODE 到 LATIN1 的轉換:
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
COMPATIBILITY 兼容性CREATE CONVERSION 是 PostgreSQL 的擴展。 在 SQL 標準裡沒有CREATE CONVERSION 語句。
SEE ALSO 參見ALTER CONVERSION [alter_conversion(7)], CREATE FUNCTION [create_function(l)], DROP CONVERSION [drop_conversion(l)]
NAMECREATE CONVERSION - define a new conversion
SYNOPSISCREATE [DEFAULT] CONVERSION name FOR source_encoding TO dest_encoding FROM funcname
DESCRIPTIONCREATE 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.
PARAMETERSDEFAULT 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;
NOTESUse DROP CONVERSION to remove user-defined conversions.
The privileges required to create a conversion may be changed in a future release.
EXAMPLESTo create a conversion from encoding UNICODE to LATIN1 using myfunc:
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
COMPATIBILITYCREATE CONVERSION is a PostgreSQL extension. There is no CREATE CONVERSION statement in the SQL standard.
SEE ALSOALTER CONVERSION [alter_conversion(7)], CREATE FUNCTION [create_function(l)], DROP CONVERSION [drop_conversion(l)]
【責任編輯:
韓亞珊TEL:(010)68476606】