ORACLE 18c XE (18.0.0.0.0) - MAX_STRING_SIZE = EXTENDED (COLLATE BINARY_CI) 问题

ORACLE 18c XE (18.0.0.0.0) - MAX_STRING_SIZE = EXTENDED (COLLATE BINARY_CI) problem

我使用以下命令将 MAX_STRING_SIZESTANDARD 设置为 EXTENDED

ALTER SYSTEM SET MAX_STRING_SIZE=EXTENDED SCOPE=spfile;

此查询已完成,“完成”。 我用这个命令检查了它:

SELECT * FROM v$parameter WHERE name = 'max_string_size';

..这里是多行格式的结果:

NAME                    max_string_size
VALUE                   EXTENDED
DISPLAY_VALUE           EXTENDED
DEFAULT_VALUE           STANDARD
ISDEFAULT               FALSE
ISSES_MODIFIABLE        FALSE
ISSYS_MODIFIABLE        IMMEDIATE
ISPDB_MODIFIABLE        TRUE
ISINSTANCE_MODIFIABLE   FALSE
ISMODIFIED              FALSE
ISADJUSTED              FALSE
ISDEPRECATED            FALSE
ISBASIC                 FALSE
DESCRIPTION             controls maximum size of VARCHAR2, NVARCHAR2, and RAW types in SQL

我想在 CREATE TABLE 中使用 COLLATE BINARY_CI 并且出现以下错误留言:

CREATE TABLE sample_db 
  (
       sample_column VARCHAR2(50) COLLATE BINARY_CI
  )

ORA-43929: Collation cannot be specified if parameter MAX_STRING_SIZE=STANDARD is set

Oracle 版本为:ORACLE 18c XE (18.0.0.0.0)

它不像 ALTER ...那么简单;见 Documentation:

Use ALTER SYSTEM only when the database is in UPGRADE mode, and run the utl32k.sql script afterward, as explained in this section.
...
The COMPATIBLE initialization parameter must be set to 12.0.0.0 or higher to set MAX_STRING_SIZE = EXTENDED.

已解决。

问题是我试图在 CDB 中修改 MAX_STRING_SIZE 参数的值而不是 PDB .

修改命令为 'XEPDB1':

PURGE DBA_RECYCLEBIN;
ALTER PLUGGABLE DATABASE XEPDB1 CLOSE IMMEDIATE;
ALTER PLUGGABLE DATABASE XEPDB1 OPEN UPGRADE;
ALTER SESSION SET CONTAINER=XEPDB1;
ALTER SYSTEM SET MAX_STRING_SIZE=EXTENDED;
@?/rdbms/admin/utl32k.sql;
ALTER PLUGGABLE DATABASE XEPDB1 CLOSE;
ALTER PLUGGABLE DATABASE XEPDB1 OPEN;

您可以遵循 oracle 文档:https://docs.oracle.com/database/121/REFRN/GUID-D424D23B-0933-425F-BC69-9C0E6724693C.htm#REFRN10321 在第 'Increasing the Maximum Size of VARCHAR2, NVARCHAR2, and RAW Columns in a PDB'.

部分

使用 sysdba 用户的命令 运行:

# list pdbs
show pdbs;

# alter session to a specific pdb
alter session set container = {pdb};

# restart pdb in upgrade mode
shutdown;
alter pluggable dabase {pdb} open upgrade;

# change max_string_size
alter system set max_string_size=extended;

# run oracle script
@${ORACLE_HOME}/admin/utl32k.sql;

# reopen as normal mode
shutdown;
alter pluggable database {pdb} open READ WRITE;

# recompile invalid objects
@${ORACLE_HOME}/rdbms/admin/utlrp.sql;

我使用了 https://hub.docker.com/r/pvargacl/oracle-xe-18.4.0 容器镜像。该页面包含连接到 sysdba 模式的指南。