使用自定义字符集在 Oracle 数据库中声明 CLOB
Declaring a CLOB in an Oracle database with a custom charset
如果数据库设置为以下字符集,是否可以声明 UTF-8 CLOB?
PARAMETER VALUE
NLS_CHARACTERSET CL8ISO8859P5
NLS_NCHAR_CHARACTERSET AL16UTF16
我尝试将字符集名称传递给声明,但看起来它只能接受对其他对象字符集的引用。
declare
clob_1 clob character set "AL32UTF8";
begin
null;
end;
/
据我所知,你不能那样做。
数据库字符集是在数据库创建期间定义的(除非重新创建数据库,否则无法更改)并且所有 character 数据类型列都以该字符集存储数据。
也许您可以尝试使用 NCLOB
数据类型,其中 "N" 表示 "national character set" 并且它将存储 Unicode 字符数据。
Unicode is a universal encoded character set that can store
information in any language using a single character set
我认为这不可能,请参阅 PL/SQL Language Fundamentals
PL/SQL uses the database character set to represent:
- Stored source text of PL/SQL units
- Character values of data types CHAR, VARCHAR2, CLOB, and LONG
因此,在您的情况下,您必须使用 NCLOB
,它使用 AL16UTF16
或尝试使用 BLOB
的解决方法。然而,这可能会变得很麻烦。
如果数据库设置为以下字符集,是否可以声明 UTF-8 CLOB?
PARAMETER VALUE
NLS_CHARACTERSET CL8ISO8859P5
NLS_NCHAR_CHARACTERSET AL16UTF16
我尝试将字符集名称传递给声明,但看起来它只能接受对其他对象字符集的引用。
declare
clob_1 clob character set "AL32UTF8";
begin
null;
end;
/
据我所知,你不能那样做。
数据库字符集是在数据库创建期间定义的(除非重新创建数据库,否则无法更改)并且所有 character 数据类型列都以该字符集存储数据。
也许您可以尝试使用 NCLOB
数据类型,其中 "N" 表示 "national character set" 并且它将存储 Unicode 字符数据。
Unicode is a universal encoded character set that can store information in any language using a single character set
我认为这不可能,请参阅 PL/SQL Language Fundamentals
PL/SQL uses the database character set to represent:
- Stored source text of PL/SQL units
- Character values of data types CHAR, VARCHAR2, CLOB, and LONG
因此,在您的情况下,您必须使用 NCLOB
,它使用 AL16UTF16
或尝试使用 BLOB
的解决方法。然而,这可能会变得很麻烦。