SCRIPT: Changing columns to CHAR length semantics ( NLS_LENGTH_SEMANTICS )
(Doc ID 313175.1)
Last updated on OCTOBER 18, 2024
Applies to:
Oracle Database Cloud Schema Service - Version N/A and laterOracle Database Cloud Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Oracle Database - Standard Edition - Version 9.0.1.0 to 11.2.0.1 [Release 9.0.1 to 11.2]
Oracle Database - Enterprise Edition - Version 9.0.1.0 to 11.2.0.1 [Release 9.0.1 to 11.2]
Information in this document applies to any platform.
Oracle Server Enterprise Edition - Version: 9.0.1.0 to 11.2.0.1.0
Goal
This script can be used if you want to change columns from BYTE semantics to CHAR semantics.
Usually you want to do this when you move from a database with a single-byte character set, to a database with a multi-byte character set. However, when columns with BYTE semantics are exported, these are recreated in the same way in the target database during the import. Setting the NLS_LENGTH_SEMANTICS parameter does not change this. The columns will always have to be changed "manually" to use CHAR semantics. Therefore you can use this script to help you achieve this.
Typical usage of this script is:
* when using exp/imp to go to a new database with a multibyte characterset like UTF8/AL32UTF8
- Export the original database.
- Import only the table definitions into the new database, without inserting the rows (ROWS=N import).
- Run (a version of) this script to change the columns to CHAR semantics.
- Import the rows into the new database using IGNORE=Y parameter for imp or the TABLE_EXISTS_ACTION=TRUNCATE option for Impdp.
* when using Csalter/alter database together with partial exp/imp to change a database to a multibyte characterset like UTF8/AL32UTF8:
- Export the "convertible" data
- truncate the "convertible" data
- change the characterset using Csalter/alter database
- Run (a version of) this script to change the columns to CHAR semantics.
- Import the exported rows back into the database using IGNORE=Y parameter for imp or the TABLE_EXISTS_ACTION=TRUNCATE option for Impdp
* When changing the semantics of existing columns from BYTE to CHAR in a database (this can be a multibyte or single byte database) without changing the NLS_CHARACTERSET simply run (a version of) the script.
More information on NLS_LENGTH_SEMANTICS is found in <Note 144808.1> Examples and limits of BYTE and CHAR semantics usage (NLS_LENGTH_SEMANTICS)
An example of this are AQ tables, where ORA-24005 is expected when running DDL against these tables.
Solution
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Goal |
Solution |
Requirements |
Configuring |
Instructions |
Script |
Sample Output |
References |