12c引入新参数,用于控制VARCHAR2, NVARCHAR2, and RAW data types的大小,RAC各实例要使用相同值
MAX_STRING_SIZE = { STANDARD(default) | EXTENDED }
STANDARD means that the length limits for Oracle Database releases prior to Oracle Database 12c apply (for example, 4000 bytes for VARCHAR2 and NVARCHAR2, and 2000 bytes for RAW).
EXTENDED means that the 32767 byte limit introduced in Oracle Database 12c applies. The COMPATIBLE initialization parameter must be set to 12.0.0.0 or higher to set MAX_STRING_SIZE = EXTENDED.
Note: You can change the value of MAX_STRING_SIZE from STANDARD to EXTENDED. However, you cannot change the value of MAX_STRING_SIZE from EXTENDED to STANDARD.
Altering MAX_STRING_SIZE will update database objects and possibly invalidate them, as follows:
1) Tables with virtual columns will be updated with new data type metadata for virtual columns of VARCHAR2(4000), 4000-byte NVARCHAR2, or RAW(2000) type.
2) Functional indexes will become unusable if a change to their associated virtual columns causes the index key to exceed index key length limits. Attempts to rebuild such indexes will fail with ORA-01450: maximum key length exceeded.
3) Views will be invalidated if they contain VARCHAR2(4000), 4000-byte NVARCHAR2, or RAW(2000) typed expression columns.
4) Materialized views will be updated with new metadata VARCHAR2(4000), 4000-byte NVARCHAR2, and RAW(2000) typed expression columns
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
更改参数方法:
1. Increasing the Maximum Size of VARCHAR2, NVARCHAR2, and RAW Columns in a Non-CDB
1)Shut down the database.
2)Restart the database in UPGRADE mode.
3)Change the setting of MAX_STRING_SIZE to EXTENDED.
4)Run the rdbms/admin/utl32k.sql script. You must be connected AS SYSDBA to run the script.
5)Restart the database in NORMAL mode.
6) Run the rdbms/admin/utlrp.sql script to recompile invalid objects. You must be connected AS SYSDBA to run the script.
Note:
The utl32k.sql script increases the maximum size of the VARCHAR2, NVARCHAR2, and RAW columns for the views where this is required.
The script does not increase the maximum size of the VARCHAR2, NVARCHAR2, and RAW columns in some views because of the way the SQL for those views is written.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2. Increasing the Maximum Size of VARCHAR2, NVARCHAR2, and RAW Columns in a CDB
1)Connect to the CDB AS SYSDBA.
ALTER SESSION SET CONTAINER=CDB$ROOT;
ALTER SYSTEM SET max_string_size=extended SCOPE=SPFILE;
注:root仍会使用standard,这步骤的目的是让所能pdb使用extended
Note: The root continues to use STANDARD semantics even after MAX_STRING_SIZE is set to EXTENDED.
The reason for setting MAX_STRING_SIZE to EXTENDED in the root is so all the PDBs in the CDB can inherit the EXTENDED setting from the root.
2) Shut down the CDB.
3) Restart the CDB in UPGRADE mode:
startup upgrade;
4) Open all the PDBs in migrate mode and then exit the database:
ALTER PLUGGABLE DATABASE ALL OPEN UPGRADE;
5) Use the catcon.pl script to run the rdbms/admin/utl32k.sql script in the root
$ cd $ORACLE_HOME/rdbms/admin
$ mkdir /scratch/mydir/utl32k_cdb_pdbs_output
$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -d $ORACLE_HOME/rdbms/admin -l '/scratch/mydir/utl32k_cdb_pdbs_output' -b utl32k_cdb_pdbs_output utl32k.sql
catcon: ALL catcon-related output will be written to [/scratch/mydir/utl32k_cdb_pdbs_output/utl32k_cdb_pdbs_output_catcon_23172.lst]
catcon: See [/scratch/mydir/utl32k_cdb_pdbs_output/utl32k_cdb_pdbs_output*.log] files for output generated by scripts
catcon: See [/scratch/mydir/utl32k_cdb_pdbs_output/utl32k_cdb_pdbs_output_*.lst] files for spool files, if any
Enter Password:
catcon.pl: completed successfully
5) Connect to the CDB AS SYSDBA and shut down the database.
6) Restart the CDB in NORMAL mode.
7) startup;
8) Open all the PDBs in the CDB:
ALTER PLUGGABLE DATABASE ALL OPEN READ WRITE;
9) Use the catcon.pl script to run the rdbms/admin/utlrp.sql script to recompile invalid objects in the root and in all the PDBs in the CDB. Enter the SYS password when prompted:
$ cd $ORACLE_HOME/rdbms/admin
$ mkdir /scratch/mydir/utlrp_cdb_pdbs_output
$ $ORACLE_HOME/perl/bin/perl $ORACLE_HOME/rdbms/admin/catcon.pl -u SYS -d $ORACLE_HOME/rdbms/admin -l '/scratch/mydir/utlrp_cdb_pdbs_output' -b utlrp_cdb_pdbs_output utlrp.sql
catcon: ALL catcon-related output will be written to [/scratch/mydir/utlrp_cdb_pdbs_output/utlrp_cdb_pdbs_output_catcon_24271.lst]
catcon: See [/scratch/mydir/utlrp_cdb_pdbs_output/utlrp_cdb_pdbs_output*.log] files for output generated by scripts
catcon: See [/scratch/mydir/utlrp_cdb_pdbs_output/utlrp_cdb_pdbs_output_*.lst] files for spool files, if any
Enter Password:
catcon.pl: completed successfully
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3. Increasing the Maximum Size of VARCHAR2, NVARCHAR2, and RAW Columns in a PDB
1) Shut down the PDB.
2) Reopen the PDB in migrate mode.
ALTER PLUGGABLE DATABASE pdb-name OPEN UPGRADE;
3) Change the setting of MAX_STRING_SIZE in the PDB to EXTENDED.
4) Run the rdbms/admin/utl32k.sql script in the PDB. You must be connected AS SYSDBA to run the utl32k.sql script.
5) Reopen the PDB in NORMAL mode.
6) Run the rdbms/admin/utlrp.sql script in the PDB to recompile invalid objects. You must be connected AS SYSDBA to run the script.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4. Increasing the Maximum Size of VARCHAR2, NVARCHAR2, and RAW Columns in an Oracle RAC Database
1) Shut down all of the Oracle RAC database instances, except one.
2) Restart the Oracle RAC database instance in UPGRADE mode.
3) Change the setting of MAX_STRING_SIZE to EXTENDED.
4) Run the rdbms/admin/utl32k.sql script in the Oracle RAC database instance. You must be connected AS SYSDBA to run the script.
5) Restart all Oracle RAC database instances in NORMAL mode.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5. Increasing the Maximum Size of VARCHAR2, NVARCHAR2, and RAW Columns in an Oracle Data Guard Logical Standby Database
1) Shut down the Oracle Data Guard primary database and logical standby database.
2) Restart the primary database and logical standby database in UPGRADE mode.
3) Change the setting of MAX_STRING_SIZE to EXTENDED on the primary database and logical standby database.
4) Run the rdbms/admin/utl32k.sql script on both the primary database and the logical standby database. You must be connected AS SYSDBA to run the script.
5) Restart the primary database and logical standby database in NORMAL mode.
6) Run the rdbms/admin/utlrp.sql script on the primary database and logical standby database to recompile invalid objects. You must be connected AS SYSDBA to run the script.
7) Restart SQL Apply.