- Current database uses WE8MSWIN1252
- Migrating to new database, considering going to AL32UTF8 encoding.
- AL32UTF8 is an Oracle UTF8 encoding of the Unicode characater set. Hence it is multibyte. WE8MSWIN1252 is a single byte character set.
- I want to use expdp/impdp to handle character set migration
What can go wrong?
- A varchar2 field declared with a max length of 4000 that contains 4000 bytes, or close to it, and contains characters that are converted to multibyte representations on import will fail with an ORA-12899. This is a complaint that the maximum length for the column has been exceeded. Why? Remember VARCHAR2 fields are constrained to 4000 bytes, not 4000 characters. Need proof? Create a sample database using the AL32UTF8 character set and try and declare a VARCHAR2(4000) column. It will fail, regardless of whether or not you use character/byte level semantics when declaring the column ala VARCHAR2(4000 CHAR).
- How To Fix:
- Convert any column you perceive as close to its 4000 character limit to a CLOB.
- You will need to precreate your tables in the schema, how?
- imdp user/pass dumpfile=test.dmp content=metadata_only data_options=skip_constraint_errors schemas=your-schema
- After precreating your schema, drop your offending varchar2 columns and then replace with CLOB columns.
- alter table my-table add(clob_column_name CLOB DEFAULT EMPTY_CLOB() NOT NULL);
- Run another data import
- Do yourself a favor and disable constraints and drop indexes before running the import below.
- imdp user/pass dumpfile=test.dmp data_options=skip_constraint_errors table_exists_action=append schemas=your-schema content=data_only
- Export Schema
- Precreate tables
- Drop offending varchar2 columns
- Replace Dropped columns with CLOBs
- Do data only import.
- Test your application for any other issues.
0 comments:
Post a Comment