Está en la página 1de 17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


Share

0 More

NextBlog

CreateBlog SignIn

Amr Blog
W ednes day, 17 July 2013

Blog Archive

NLS_CHARACTERSET for BOTH ARABIC and FRENCH

2013 (20)
September (1)
July (19)

ChangingtheNLS_CHARACTERSETtoAL32UTF8/UTF8(Unicode)[ID260192.1]
Modified: May23,2013

Type: BULLETIN

Status: PUBLISHED

Priority: 1

HP UX X11 forwording wasn't enabled


ToBottom
nothing but re...

Oralce datafile movement to different


mount point....

Comments(0)

NLS_CHARACTERSET for BOTH ARABIC


and FRENCH

InthisDocument
Purpose

Scope

Moving Undo Tablespace from one


location to anothe...

Details

Tablespace shrinking

1)GeneralremarksongoingtoAL32UTF8

1.a)Prerequisites:

1.b)WhenchanginganOracleApplicationsDatabase:

1.c)Whentouse(full)export/importandwhentouseAlterDatabaseCharacterSet/Csalter?

1.d)WhenusingExpdp/Impdp(DataPump)

1.e)UsingAlterDatabaseCharacterSeton9i

1.f)WhataboutPhysical/LogicalStandbydatabases?

1.G)Howtotestthestepsinthisnoteupfront?

purge Recyclebin
Old Files deletion
ls l, df h , df k
Monitoring Services of a Listener
How to grant on v$ views
Tablespace shrinking: ORA03297 file
contains blo...
ORA01031: insufficient privileges

2)Checkthesourcedatabaseforunneededorproblematicobjects:

2.a)Invalidobjects.

drop table [Oracle SQL]

2.b)OrphanedDatapumpmastertables(10gandup)

2.c)Unneededsampleschema/users.

Dropping a connected user from an


Oracle 10g datab...

2.d)LeftoverTemporarytablesusingCHARsemantics.

2.e)Makesureyourdatabaseisingoodhealth.

3.a)Howto"rescue"lossydata?

3.b)CanIsolve"lossy"user/applicationdatainanotherway?

4)Checkfor"Convertible"and"Truncation"datawhengoingtoAL32UTF8

5)Dealingwith"Truncation"data.

5a)orshortenthedatabeforeexport

5b)oradaptthecolumnstofittheexpansionofthedata

6.a)"Convertible"ApplicationData:

6.b)"Convertible"datainDataDictionaryobjects:
7)BeforeusingCsalter/AlterDatabaseCharacterSetcheckthedatabasefor:

7.a)PartitionsusingCHARsemantics:

7.b)Function,DomainorJoinedindexesonCHARsemanticscolumns.

7.d)ClustersusingCHARsemantics.

7.e)UnusedcolumnsusingCHARsemantics

7.f)CheckthatyouhaveenoughroomtorunCsalterortoimportthe"Convertible"dataagainafterwards.

7.g)Objectsintherecyclebin(10gandup)

About Me

Amaranath
View my complete profile

7.h)Checkifthecompatibleparameterissettoyourbaseversion
8)Afterany"Lossy"issolved,"Truncation"dataisplannedtobeaddressedand/or"Convertible"exported/truncated/addressedandpoint7)isokrunCsscanagainasfinalcheck.
8.a)For8i/9itheCsscanoutputneedstobe"Changeless"forallCHAR,VARCHAR2,CLOBandLONGdata(DataDictionaryandUser/Applicationdata).
8.b)For10ganduptheCsscanoutputneedstobe
9)SummaryofstepsneededtouseAlterDatabaseCharacterSet/Csalter:
9.a)For9iandlower:
9.b)For10gandup:
10)RunningCsalter(10gand11g)orAlterDatabaseCharacterSet(8iand9i)

10.a)Thestepsfor8iand9iONLY

10.b)Thestepsforversion10gand11g

ORA00333: redo log read error block


41017 count 7...

7.b.2)JoinindexesoncolumnsusingCHARsemantics
7.c)SYSTIMESTAMPintheDEFAULTvalueclausefortablesusingCHARsemantics.

ORA01658: unable to create INITIAL


extent for seg...

7.b.1)FunctionalordomainindexesoncolumnsusingCHARsemantics

Identifying High CPU Usage with vmstat

6)Dealingwith"Convertible"data.

HowTo: Add Jobs To cron Under Linux


or UNIX?

3)ChecktheSourcedatabasefor"Lossy"(invalidcodepointsinthecurrentsourcecharacterset).

Routine Health Check Up of Your


Oracle Database ...

10.c)ChecktheCsalter/alterdatabaseoutputandthealert.logforerrors,someCsaltermessagesdoNOThaveanORAnumber.

11)ReloadthedatapumppackagesafterachangetoAL32UTF8in10gandup.

12)Importtheexporteddata.

12.a)WhenusingCsalter/AlterdatabasetogotoAL32UTF8andtherewas"Truncation"datainthecsscandoneinpoint4:

12.b)Whenusing(Full)export/importtogotoanew/otherAL32UTF8databaseandtherewas"Truncation"datainthecsscandoneinpoint4:

12.c)WhenusingCsalter/AlterdatabasetogotoAL32UTF8andtherewasNO"Truncation"data,only"Convertible"and"Changeless"inthecsscandoneinpoint4:

12.d)Whenusing(full)export/importtogotoanew/otherAL32UTF8databaseandtherewasNO"Truncation"data,only"Convertible"and"Changeless"inthecsscandoneinpoint4:

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

1/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH

13)Checkyourdataandfinalthings:
References

Appliesto:
OracleDatabaseEnterpriseEditionVersion8.0.3.0to11.2.0.4[Release8.0.3to11.2]
OracleDatabaseStandardEditionVersion8.0.3.0to11.2.0.4[Release8.0.3to11.2]
Informationinthisdocumentappliestoanyplatform.

Purpose
ToprovideaguidetochangetheNLS_CHARACTERSETtoAL32UTF8orUTF8.
Thisnotewillonlydealwiththedatabase(serverside)changeitself.
ForfurtherimplicationsonclientsandapplicationlevelwhengoingtoAL32UTF8pleaseseeNote788156.1AL32UTF8/UTF8(Unicode)DatabaseCharacterSetImplications.
It'sstronglyrecommendedto:
doacomplete"testdrive"oftheWHOLEchangeupfront
readNote788156.1AL32UTF8/UTF8(Unicode)DatabaseCharacterSetImplicationsfirstandtomakesureyourapplicationandclientsarecheckedandreadyforthechangeondatabaselevel.
ThisnotewasspecifictoFROM:WE8ISO8859P1,WE8ISO8859P15orWE8MSWIN1252TO:AL32UTF8orUTF8
ThecurrentnotehowevercanbeusedtogofromanyNLS_CHARACTERSETtoAL32UTF8/UTF8.(whichalsomeansitcanbeusedtogofromUTF8toAL32UTF8(orinverse)).
ThenoteiswrittenusingAL32UTF8,tousethisnotetogotoanothercharacterset(forexampleUTF8)simplyreplace"AL32UTF8"with"UTF8"intheCSSCANTOCHARandfor9iandlowerinthealterdatabasecharactersetcommand.

This"flow"canalsobeusedtogofromanysinglebytecharacterset(likeUS7ASCII,WE8DEC)toanyotherMultibytecharacterset(ZHS16GBK,ZHT16MSWIN950,ZHT16HKSCS,ZHT16HKSCS31,KO16MSWIN949,JA16SJIS...),simplys
xx16xxxxtargetcharacterset.ButinthatcasegoingtoAL32UTF8wouldbesimplybeafarbetteridea.Note333489.1ChoosingadatabasecharactersetmeanschoosingUnicode.
In8i(8.1.7andlower)youcannotuseAL32UTF8seenthisisnotknown,useUTF8instead.
In10gand11gyouNEEDtouseCsalter.DoNOTuse"Alterdatabasecharacterset",using"Alterdatabasecharacterset"isNOTsupportedin10gand11g.
FromOracle12conwards,theDMUwillbetheonlytoolavailabletomigratetoUnicode.

Scope
AnyDBAchangingthecurrentNLS_CHARACTERSETtoAL32UTF8/UTF8oranothermultibytecharacterset.
InthisnoteAL32UTF8willbeused,butit'sapplicabletoUTF8(liketobeusedin8iinsteadofAL32UTF8)orothermultibytecharactersetsalso.
ThecurrentNLS_CHARACTERSETisseeninNLS_DATABASE_PARAMETERS.

Sqlplus/assysdba
SELECTvalueFROMNLS_DATABASE_PARAMETERSWHEREparameter='NLS_CHARACTERSET'
/
TheNLS_CHARACTERSETisdefiningthecharactersetoftheCHAR,VARCHAR2,LONGandCLOBdatatypes.

Details
1)GeneralremarksongoingtoAL32UTF8
ThisnotedocumentsthesteptosafelychangetoUnicodebytheusageof
*for8iand9iCsscanand"Alterdatabase"combinedwithapartialExport/Import
*for10gand11.2gCsscanandCsaltercombinedwithpartialExport/Import
*for8iupto11.2gCsscanwithfullExport/Databaserecreation/Import.

FormigrationtoAL32UTF8(andthedeprecatedUTF8),thereisanewtoolavailablecalledtheDatabaseMigrationAssistantforUnicode(DMU).TheDMUisauniquenextgenerationmigrationtoolprovidinganendtoendsolutionform
encodingstoUnicode.DMU'sintuitiveuserinterfacegreatlysimplifiesthemigrationprocessandlessenstheneedforcharactersetmigrationexpertisebyguidingtheDBAthroughtheentiremigrationprocessaswellasautomatingman
TheDMUtoolissupportedagainstOracle11.2.0.3andhigherandselectedolderversionsandplatformcombinations.
FormoreinformationpleaseseeNote1272374.1TheDatabaseMigrationAssistantforUnicode(DMU)ToolandtheDMUpagesonOTN.
FromOracle12conwards,DMUwillbetheonlytoolavailabletomigratetoUnicode.

1.a)Prerequisites:
InthisnotetheCsscantoolisused.Pleaseinstallthisfirst
Note458122.1InstallingandconfiguringCSSCANin8iand9i
Note745809.1InstallingandconfiguringCSSCANin10gand11g
TohaveanoverviewoftheoutputandwhatitmeanspleaseseeNote444701.1Csscanoutputexplained

1.b)WhenchanginganOracleApplicationsDatabase:
PleaseseethefollowingnoteforanOracleApplicationsdatabase:Note124721.1MigratinganApplicationsInstallationtoaNewCharacterSet.
ThisistheonlywaysupportedbyOracleapplications.IfyouhaveanydoubtloganOracleApplicationsSRforassistance.

1.c)Whentouse(full)export/importandwhentouseAlterDatabaseCharacterSet/Csalter?
With"Fullexp/imp"ismeanttotakeanexportandimportthecompletedatasetintoaNEWAL32UTF8database(thismaybeanotherOracleversionorOSplatform).
Fullexp/impcanbeusedatanytime.ToavoiddatalosspleasedocheckyoursourcedatabasebeforedoingtheexportwithCsscan(=followthisnoteuntilpoint6andthengotostep12).

UsingAlterDatabaseCharacterSet/CsaltertochangetheNLS_CHARACTERSETofanexistingdatabaseinsteadofafullexport/importhasan(down)timeadvantagewhentheamountof"Convertible"userdataislowcomparedtotheamo
"Changeless"dataneedsnoaction)and/orwhenrecreatingthedatabasewilltakealotoftimebutisingeneralsomewhatmorecomplex.
Theendresultofbothway'sofdoingthechangeishoweverthesame.

IfonlycertainschemaortablesneedtobemovedtoanotherornewAL32UTF8database(thismaybeanotherOracleversionorOSplatform)then,toavoiddatalosspleasedocheckyoursourcedatabasewithCsscan(=followthisnoteu
Onecanthenadaptthecsscansyntaxinstep4toonlyscantheschemauserortable(s)thataregoingtobeexported.
ExamplesofotherthanFULL=YcsscansyntaxcanbefoundinNote1297961.1ORA01401/ORA12899WhileImportingDataInAnAL32UTF8/UTF8(Unicode)OrOtherMultibyteNLS_CHARACTERSETDatabase.
WedohoweversuggesttodoinanycasetheFULL=Yscaninpoint3inhisnoteseenthisismorea"healthcheck"andifthereisanycorrectionneededthisneedsinalmostalcasestobedoneondatabaselevel.

1.d)WhenusingExpdp/Impdp(DataPump)
DoNOTuseExpdp/Impdpwhengoingto(AL32)UTF8oranothermultibytecharactersetonALL10gversionslowerthen10.2.0.4(including10.1.0.5).Also11.1.0.6isaffected.
ItwillprovokedatacorruptionunlessPatch5874989isappliedontheImpdpside.Expdpisnotaffected,hencethedatainthedumpfileiscorrect.Alsothe"old"exp/imptoolsarenotaffected.
Thisproblemisfixedinthe10.2.0.4and11.1.0.7patchset.
Fixedin11.2.0.1andup
Forwindowsthefixisincludedin
10.1.0.5.0Patch20(10.1.0.5.20P)orlater,seeNote276548.1.
10.2.0.3.0Patch11(10.2.0.3.11P)orlater,seeNote342443.1.

1.e)UsingAlterDatabaseCharacterSeton9i
For9isystemspleasemakesureyouareatleastonPatchset9.2.0.4,seeNote250802.1Changingcharactersettakesaverylongtimeanduseslotsofrollbackspace

1.f)WhataboutPhysical/LogicalStandbydatabases?
IfyoursystemhasaLogicalStandbydatabasethisLogicalstandbyneedstoberecreatedfromthe"main"databaseafterthecharactersetconversion,thereisnosupportedwaytoalterthestandbytogetherwiththemaindatabase.

SeentheLogicalstandbydatabaseneedstohavethesameNLS_CHARACTERSETasthesourcedatabaseit'salsonotpossibletoforexamplechangeaLogicalstandbydatabaseandthen,afterchangingtheNLS_CHARACTERSETofthelo
theredoofthemaindatabasetothisdatabase.
ForPhysicalStandbyslowerthan11.1.0.7thePhysicalStandbyalsoneedstoberecreated.
From11.1.0.7onwardsthisisnotneededanymoreforPhysicalStandbys,pleaseseeNote1124165.1ChangingPrimaryDatabaseCharacterSetwithoutRecreatingDataGuardPhysicalStandbys

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

2/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


From11.1.0.7onwardsthisisnotneededanymoreforPhysicalStandbys,pleaseseeNote1124165.1ChangingPrimaryDatabaseCharacterSetwithoutRecreatingDataGuardPhysicalStandbys

1.G)Howtotestthestepsinthisnoteupfront?
Toproperlytestthe*database*changes(=thestepsinthisnote)youwillneedtodothesteps:
whenusingCsalter/alterdatabaseonaphysicalCOPYofthedatabaseyouwanttoconvert.

whenusingexport/importtogotoanewAL32UTF8databaseonORaphysicalCOPYofthedatabaseyouwanttoexportORatestdatabasethathastheSAMENLS_CHARACTERSETasthecurrentNLS_CHARACTERSETandthenex
youareplanningtomovetothenewAL32UTF8intothistestdatabase.

2)Checkthesourcedatabaseforunneededorproblematicobjects:
tipfor(10gandup):removefirstallobjectsintherecyclebin

Sqlplus/assysdba
SELECTOWNER,ORIGINAL_NAME,OBJECT_NAME,TYPEFROMdba_recyclebinORDERBY1,2
/
Ifthereareobjectsintherecyclebinthenperform

Sqlplus/assysdba
PURGEDBA_RECYCLEBIN
/
Thiswillremoveunneededobjectsandavoidconfusioninfollowingsteps.Itmightbeagoodideatosimplydisabletherecyclebinuntilthechangeisdonebysettingtherecyclebin='OFF'parameter

2.a)Invalidobjects.
Sqlplus/assysdba
SELECTowner,
object_name,
object_type,
status
FROMdba_objects
WHEREstatus='INVALID'
/
Ifthereareanyinvalidobjectsrunutlrp.sql

SQL>@?/rdbms/admin/utlrp.sql
Ifthereareanyleftafterrunningutlrp.sqlthenpleasemanuallyresolve/droptheinvalidobjects.

2.b)OrphanedDatapumpmastertables(10gandup)
Sqlplus/assysdba
SELECTo.status,
o.object_id,
o.object_type,
o.owner
||'.'
||object_name"OWNER.OBJECT"
FROMdba_objectso,
dba_datapump_jobsj
WHEREo.owner=j.owner_name
ANDo.object_name=j.job_name
ANDj.job_nameNOTLIKE'BIN$%'
ORDERBY4,2
/
SeeNote336014.1HowToCleanupOrphanedDataPumpJobsInDBA_DATAPUMP_JOBS?

2.c)Unneededsampleschema/users.
The'HR','OE','SH','PM','IX','BI'and'SCOTT'usersaresampleschemausers.Thereisnopointinhavingthesesampleschemainaproductionsystem.Ifasampleschemaexistwesuggesttoremoveit.
ThisnoteisusefultoidentifyusersinyourdatabaseNote160861.1OracleCreatedDatabaseUsers:Password,UsageandFiles.
AnotheruserthatmightberemovedisSQLTXPLAINfromNote215187.1
IfyoudonotuseAPEX(OracleApplicationExpress)/HTMLDBtheFLOWS_xxxxandAPEX_xxxxuserscanalsobedroppedNote558340.1HowtoUninstallOracleHTMLDB/ApplicationExpressfromtheDatabase?

2.d)LeftoverTemporarytablesusingCHARsemantics.
Sqlplus/assysdba
SELECTC.owner
||'.'
||C.table_name
||'.'
||C.column_name
||'('
||C.data_type
||''
||C.char_length
||'CHAR)'
FROMall_tab_columnsC
WHEREC.char_used='C'
ANDC.table_nameIN
(SELECTtable_nameFROMdba_tablesWHERETEMPORARY='Y'
)
ANDC.data_typeIN('VARCHAR2','CHAR')
ORDERBY1
/
ThesetablesMAY(!)giveduringAlterdatabaseCharterSetorCsalter

ERRORatline1:
ORA00604:erroroccurredatrecursiveSQLlevel1
ORA14450:attempttoaccessatransactionaltemptablealreadyinuse.

Temporarytablesshouldberecreatedbytheapplicationwhenneeded,soifyouhavetableslistedbyaboveselectit'sgoodideatoconfirmtheapplicationwillrecreatethemifneededanddropthemnow(orifthedbisstillinusenow,do
point7inthisnote).
IfthereportedtablesareSYS.ORA_TEMP_X_DS_XXXX(likeSYS.ORA_TEMP_1_DS_27681,SYS.ORA_TEMP_1_DS_27686)theyareleftoversofDBMS_STATS(note:4157602.8)sotheycanbedroppedwithoutproblemsatanytime.

2.e)Makesureyourdatabaseisingoodhealth.
ItmightbeagoodideatorunNote456468.1IdentifyDataDictionaryInconsistencyandNOTE136697.1"hcheck8i.sql"scripttocheckforknownproblemsinOracle8i,Oracle9i,andOracle10g
orforOracle11gNote466920.1:11gNewFeatureHealthmonitor

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

3/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


orforOracle11gNote466920.1:11gNewFeatureHealthmonitor

3)ChecktheSourcedatabasefor"Lossy"(invalidcodepointsinthecurrentsourcecharacterset).
RunCsscanwiththefollowingsyntax:

$csscan\"sys/<syspassword>@<TNSalias>assysdba\"FULL=YFROMCHAR=<currentNLS_CHARACTERSET>TOCHAR=<currentNLS_CHARACTERSET>LOG=dbcheckCAPTURE
PROCESS=2
*AlwaysrunCsscanconnectingwitha'sysdba'connection/user,donotuse"system"or"csmig"user.
*The<currentNLS_CHARACTERSET>isseeninNLS_DATABASE_PARAMETERS.

conn/ASsysdba
SELECTvalueFROMNLS_DATABASE_PARAMETERSWHEREparameter='NLS_CHARACTERSET'
/

*TheTOCHAR=<currentNLS_CHARACTERSET>isnotatypo,theideaistochecktheCURRENTcharactersetforcodeswhoarenotdefinedinthisNLS_CHARACTERSETbeforechangingtheNLS_CHARACTERSET
*ThePROCESS=parameterinfluencestheloadonyoursystem,thehigherthisis(6or8forexample)thefasterCsscanwillbedone,thelowerthisisthelessimpactitwillhaveonyoursystem.Adaptifneeded.
*ThecsscanSUPPRESSparameterlimitsthesizeofthe.errfilebylimitingtheamountofinformationlogged/table.UsingSUPPRESS=1000willlogmax1000rowsforeachtableinthe.errfile.Itwillnotaffecttheinformationinthe.txt
the.errfile.Thisismainlyusefulforthefirstscanofbigdatabases,ifyouhavenoideahowmuch"Convertible"or"Lossy"thereisinadatabasethenthiswillavoidthatthe.errfilebecomes100'sofMBbiganditlimitsalsothespaceuse
Csmigschema.
*DonotspecifytheTONCHARorFROMNCHARcsscanparameters,thosearetochangetheNLS_NCHAR_CHARACTERSET.Againtheyarenotneededandshouldnotbespecified.
OnceCsscanisactuallyscanningthetablesv$session_longopscanbeusedtoseetheprogressofscansofbigtables:

Sqlplus/assysdba
SETpages1000
SELECTtarget,
TO_CHAR(start_time,'HH24:MI:SSDDMMYY'),
time_remaining,
sofar,
totalwork,
sid,
serial#,
opname
FROMv$session_longops
WHEREsidIN
(SELECTsidFROMv$sessionWHEREupper(program)LIKE'CSSCAN%'
)
ANDsofar<totalwork
ORDERBYstart_time
/
Csscanwillcreate3files:
dbcheck.outalogoftheoutputofcsscan
dbcheck.txtaDatabaseScanSummaryReport
dbcheck.errcontainstherowid'softheLossyrowsreportedindbcheck.txt(ifany).
ThisCsscanistocheckifalldataisstoredcorrectlyinthecurrentcharacterset.BecausetheTOCHARandFROMCHARcharactersetsasthesametherecannotbeany"Convertible"or"Truncation"datareportedindbcheck.txt.
Ifallthedatainthedatabaseisstoredcorrectlyatthemomentthenthereisonly"Changeless"datareportedindbcheck.txt.Ifthisisthecasepleasegotopoint4).
Ifthereisany"Lossy"datathenthoserowscontaincodepointsthatarenotcurrentlydefined correctlyandtheyshouldbeclearedupbeforeyoucancontinue.
Ifthis"Lossy"isnotchecked/correctedthenthis"Lossy"dataWILLBELOST.
Pleaseseethefollowingnotemoreinformationabout"Lossy"dataNote444701.1Csscanoutputexplained.

Oneexceptionis"binary"or"Encrypteddata"storedinCHAR,VARCHAR2orCLOB,thisisnotsupported.TheONLYsupporteddatatypestostore"raw"binarydata(likePDF,doc,docx,jpeg,png,etcfiles)orencrypteddatalikehas
RAWorBLOB.
Ifyouwanttostorebinarydata(likePDF,doc,docx,jpeg,png,etcfiles)orencrypteddatalikehashed/encryptedpasswordsinCHAR,VARCHAR2,LONGorCLOBdatatypethanthismustbeconvertedtoa"charactersetsafe"repres
anychangeoftheNLS_CHARACTERSET.
SeeNote1297507.1Problemswith(Importing)EncryptedDataAfterCharacterSetChangeUsingOtherNLS_CHARACTERSETDatabaseorUpgradingthe(client)OracleVersion

3.a)Howto"rescue"lossydata?

Thefirstthingtodoistrytofindoutwhattheactualencodingisofthe"Lossy"data,thisisextensivlydocumentedinNote444701.1Csscanoutputexplained.sections"C.2)Thesourcedatabasehasdata(codes)thatareNOTdefinedinthe
limitofwhatCsscancandetectwhendealingwithlossy,anexample:"

ThemostcommonsituationiswhenhavinganUS7ASCII/WE8ISO8859P1databaseand"Lossy",inthiscasechangingyourUS7ASCII/WE8ISO8859P1SOURCEdatabasetoWE8MSWIN1252usingAlterDatabaseCharacterSet/Csalterw
isexplainedinNote252352.1EuroSymbolTurnsupasUpsideDownQuestionmark.TheflowtodothisisfoundinNote555823.1ChangingUS7ASCIIorWE8ISO8859P1toWE8MSWIN1252
NotethatusingCsscanaloneisnotenough,youwillneedtocheckyourwholeenvironmenttodeducttherealencodingofthedata.
DonotblindlyassumeALLyourdataisWE8MSWIN1252andthisdoesnotmeanALLlossycanbe"solved"bygoingtoWE8MSWIN1252.
Itcannotberepeatedenoughthat:

IfLOSSYneedtobesaved/correctedthenitisNEEDEDtochangetheNLS_CHARACTERSETFIRSTtothe"real"charactersetoftheLOSSYinthesourcedatabaseBEFOREgoingtoAL32UTF8.IfyourWE8ISO8859P1databasehasfo
NEEDtogomostlikelytoIW8MSWIN1255beforegoingtoAL32UTF8seenWE8ISO8859P1simplydoesnotdefineHebrew.

InsomecasesitisNOTpossiblethe"correct"the"Lossy"databychangingtheNLS_CHARACTERSETforallrowsandthenthebestsolutionistoupdatethoserowswithsomethingmeaningfulusingOracleSqlDeveloper.Downloadth
fromhttp://www.oracle.com/technetwork/developertools/sqldeveloper/downloads/.DoNOTuseToad,sqlplus,etc.
DoNOTuseexp/impto"correct"lossy,forexamplesettingtheNLS_LANGtoWE8MSWIN1252whileexporting"Lossy"datafromaWE8ISO8859P1databasewillNOTsolvethelossy,thatdataWILLbelost.
Whenpreparingatestenvironmenttodebugthisyoucanuse2things:
arestoredphysicalcopy(backup)ofthedatabase

anexport/importofthedatasetinadatabasewiththesameNLS_CHARACTERSETasthecurrentsourcedatabase.Thiscanalsobeusedifthecurrentdatabasecannotbe"corrected"(itisforexemplestillusedbyotherapplicationse
datasettoa"temporary"databasewhousesthesameNLS_CHARACTERSETasthecurrentsourcedatabase,correctthisdatabaseandthengofromthatdatabasetoanAL32UTF8databaseusingexp/imp.
note:IfyouusethisnotetogofromAL32UTF8toUTF8(orinverse)andyouhavelossythenlogaSRandaskforareviewbythe"AdvancedResolutionTeam".
ThisselectwillgiveallthelossyobjectsfoundinthelastCssanrun:
NotethatwhenusingthecsscanSUPPRESSparameterthisselectmaygiveincompleteresults(notalltables).

Sqlplus/assysdba
SELECTDISTINCTz.owner_name
||'.'
||z.table_name
||'('
||z.column_name
||')'
||z.column_type
||''LossyColumns
FROMcsmig.csmv$errorsz
WHEREz.error_type='DATA_LOSS'
ORDERBYLossyColumns

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

4/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


ORDERBYLossyColumns
/
LossyinDataDictionaryobjects
WhenusingCsalter/AlterDatabaseCharacterSet:
Most"Lossy"intheDataDictionaryobjectswillbecorrectedbycorrectingthedatabaseasawhole,iftheonly"lossy"isfoundinDataDictionaryobjectsthenfollowthetipsfor"Convertible"DataDictionarydata.
Forexampleonecommonthingseenis"Lossy"foundonlyinSYS.SOURCE$,mostofthetimethismeanssomepackagesourcecodecontainillegalcodes/baddata.
YoucanusetheselectsfoundinNote291858.1"SYS.SOURCE$markedashavingConvertibleorLossydatainCsscanoutput"tofindwhatobjectsareaffected.
NotethatyouCANNOT"fix"tableslikeSYS.SOURCE$itself,youneedtorecreatetheobjectswho'stextisstoredinSYS.SOURCE$.
DoNOTtruncateorexportDataDictionaryobjectsitselfunlessthisissaidtobepossibleinNote258904.1.
Whenusingfullexport/importintoanewAL32UTF8database:
Whenusingexport/importtoanewdatabasethen"Lossy"inDataDictionaryobjectsisonlyrelevantwhenitconcerns"Applicationdata".
Thethingtocheckforistoseeifthereisno"lossy"intableslikeSYS.SOURCE$(packagesourcecode)/SYS.COM$(commentsonobjects)/SYS.VIEW$(viewdefinitions)/SYS.COL$(columnnames)orSYS.TRIGGER$(triggers).
ThereasonbeeingissimplythattheseDataDictionaryobjectsobjectscontaininformationaboutuserobjectsorpl/sqlcode.Ifyouhave"convertible"therethat'snotaanissue.
Formostconversions,ifthereis"lossy"itwillbeinSYS.SOURCE$.

3.b)CanIsolve"lossy"user/applicationdatainanotherway?
yes,itispossibleto:

removethe'lossy"rowsorupdatethese"lossy"rowswith"meaningful"datausingUS7ASCII(AZ,az,09)charactersusingOracleSqlDeveloper.Downloadthelatestversionfromhttp://www.oracle.com/technetwork/developertools
NOTuseToad,sqlplus,etc.

treatthe"lossy"inuser/applicationdataas"convertible"(=needtoexportanddelete/reimpaftercsalter),ifyouexp/expdpthe"lossy"dataandimp/imdpditintoanAL32UTF8database(whichcanbethecurrentdatabaseafter
"lossy"characterswillsimplybecometheUnicodereplacementcharacter.Forexampleastringlike"abcef"storedinanUS7ASCIIdb(US7ASCIIdoesnotdefinesotheis"lossy")willbecome"abcef".Notethat
butoften rowswithalotoflossywillbealso"truncation"(andthatneedstobeadressed,seebelow).

4)Checkfor"Convertible"and"Truncation"datawhengoingtoAL32UTF8
Iftherewasno"Lossy"instep3oryoucorrectedtheNLS_CHARACTERSETandstartedoverthenruncsscanwiththefollowingsyntax:

$csscan\"sys/<syspassword>@<TNSalias>assysdba\"FULL=YTOCHAR=AL32UTF8LOG=TOUTF8CAPTURE=YARRAY=1000000PROCESS=2
NotetheusageofCAPTURE=Y,usingCAPTURE=N(thedefault)willspeedupcsscanprocessitselfandusefarlessspaceintheCSMIGtablespacebuttheselectinpoint6a)willthenNOTlistthe"Convertible"Userdata.
The.txtfilewillalwayslisttheconvertibleuserdataregardlessofthesettingofCAPTURE.
ForverybigdatabasesitmightbeanideatoruncsscanfirstusingCAPTURE=Nasfirstscantohaveanideaaboutthedatasetandthen,ifneeded,dotableoruserlevelscanstoknowwhatexactrowsareconvertible.
Ifthereisalotof"Convertible"Applicationdatainyourdatabasethenthecreationofthe.errfilewilltakeconsiderableamountoftimewhenusingCAPTURE=Y.
Whencreatingthe.errfilecsscanwillfetchthefirst30bytesofeachloggedrowinthe.errfiletogetherwiththerowidandwhyit'slogged
Csscanwilldothisfor
*"Truncation"and"Lossy"rowsand"Convertibledatadictionary"dataifCAPTURE=N
*ALL"Convertible"(applicationdataalso),"Truncation"and"Lossy"rowsifCAPTURE=Y
Csscanwillcreate3files:
toutf8.outalogoftheoutputofcsscan
toutf8.txttheDatabaseScanSummaryReport
toutf8.errcontainstherowid'softheConvertibleandLossyrowsreportedintoutf8.txt
WhengoingtoUTF8orAL32UTF8thereshouldnormallybeNOentriesunder"Lossy"intoutf8.txt,becausetheyshouldhavebeenfilteredoutinstep3),ifthereis"Lossy"datathenmakesureyouacceptthisdatawillbecome

note:ifyouusethisnotenottogotoUTF8orAL32UTF8buttogoanyotherMultibytecharacterset(ZHS16GBK,ZHT16MSWIN950,ZHT16HKSCS,ZHT16HKSCS31,KO16MSWIN949,JA16SJIS...),thenthereCANbe"Lossy".Thisisdat
andthisthenneedstoberemovedbeforegoingfurtherorexp/impneedstobeusedforalltablesthathave"lossy"exp/impwillthenremovethislossy.
Ifthereareinthetxtfile:
Entriesunder"Truncation"thengotostep5)
Entriesfor"Convertible"and"Changeless"butno"Truncation"thengotostep6).
IfyouhaveNOentry'sunderthe"Convertible","Truncation"or"Lossy"(thisisnotoftenseen)andalldataisreportedas"Changeless"thenproceedtostep7).
TohaveanoverviewoftheoutputandwhatitmeanspleaseseeNote444701.1Csscanoutputexplained

Note:Whenusingexport/importandthereisonlyneedtoexportandimportcertainschema'sintoanew/otherAL32UTF8databaseitisalsopossibletousecsscanonlyontheactualschemauserortableswhowillbeexported.Thiswillr
csscanrunbyonlycheckingtheactualaffecteddataset.
Syntaxexamplesarefoundinnote1297961.1ORA01401/ORA12899WhileImportingDataInAnAL32UTF8/UTF8(Unicode)OrOtherMultibyteNLS_CHARACTERSETDatabase.
Toavoidconfusion:whenusingCsalteroralterdatabaseyouNEEDtousetheFULL=Ysyntaxhereinpoint4)

5)Dealingwith"Truncation"data.
AsexplainedinNote788156.1,charactersmayusemoreBYTESinAL32UTF8theninthesourcecharacterset.Truncationdatameansthisrowwon'tfitinthecurrentcolumndefinitiononceconvertedtoAL32UTF8.

"Truncation"dataisalwaysalso"Convertible"data,whichmeansthatwhateverwayyoudothechange,theserowshavetobeexportedbeforethecharactersetischangedandreimportedafterthecharactersethaschanged.Ifyouproc
truncationissuethentheimportwillfailonthesecolumnswith"ORA01401:insertedvaluetoolargeforcolumn"(orfrom10gonwards"ORA12899:valuetoolargeforcolumn...")becausethesizeofthedataexceedsthemaximumsizeof
Note:sometimesthereisalsoalistoftablesatthenendofthetoutf8.txtundertheheader[TruncationDueToCharacterSemantics],thisisnotthesameasthetruncationthissectiondiscusses.
WhenusingCsalter/Alterdatabaseand/or(full)export/importtheobjectsunderthe[TrunationDueToCharacterSemantics]headercanbesimplyignored.(forthegoodorder,onlyunderthisheader.....)
Truncationissueswillalwaysrequiresomework,thereareanumberofwaystodealwiththem:
Thereare2mainoptions:

5a)orshortenthedatabeforeexport

Ascriptthatgivesanideaonhowtodothis,basedonthecsscanresultoftheLASTrun(CsscanwillonlykeepONEresultset),isfoundinNote1231922.1ScripttoSolveTruncationinCsscanoutputbyShorteningDataBeforeConversion
Noteofcoursethatthiswillprovokedataloss,sothisnotoftenagoodalternative.

5b)oradaptthecolumnstofittheexpansionofthedata
Forsomecolumnsitmightbeneededtochangedatatype:
*forCHARdatathatbecomesmorethan2000bytesafterconversiontoAL32UTF8youneedto:
changetheCHARcolumntoVARCHAR2beforeexportonthesourceside
OR
precreatetheCHARcolumnasVARCHAR2ontheimport(AL32UTF8)side.
*forVARCHAR2datathatbecomesmorethan4000bytesafterconversiontoAL32UTF8youneedto:

changetheVARCHAR2columntoCLOBbeforeexportonthesourceside
OR
precreatetheVARCHAR2columnasCLOBontheimport(AL32UTF8)side.PrecreatingCLOBwillonlyworkwhenusingDataPump,the"old"imp/exptoolswillfailwithIMP00058:ORACLEerror1461encountered,ORA01461:canbind
LONGcolumn

Note:theneedforadatatypechangeisnotoftenseen,butispossible.IftheexpansioninBYTESisbiggerthenthemaxdatalengthofthedatatype,whichis2000bytesforCHARand4000bytesforVARCHAR2,thenusingCHARseman
Formostcolumnschangingthecolumndatatype"size"willbeenough,youhaveagain2choices:
*AdaptthecolumnsizeinBYTESfordatathatbecomesNOTmorethan2000bytes(forCHAR)/4000bytes(forVARCHAR2)afterconversiontoAL32UTF8.
youcan:
changethecolumn(s)sizeinBYTEstotheminimumneedsizebeforeexportonthesourceside

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

5/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


changethecolumn(s)sizeinBYTEstotheminimumneedsizebeforeexportonthesourceside
OR
precreatethetablewithenlargedcolumn(s)sizeinBYTEsontheimport(AL32UTF8)side

*ChangethecolumnstoCHARsemanticsfordatathatbecomesNOTmorethan2000bytes(forCHAR)/4000bytes(forVARCHAR2)afterconversiontoAL32UTF8.
youcan:
changethecolumn(s)toCHARsemanticsbeforeexportonthesourceside
OR
precreatethetableusingCHARsemanticsontheimport(AL32UTF8)side
HowtouseCHARsemanticsisdiscussedinnote144808.1ExamplesandlimitsofBYTEandCHARsemanticsusage(NLS_LENGTH_SEMANTICS)
Youwillneedtoadaptatleastthereported"Truncation"columns,ingeneralhoweveritisbettertochangeallcolumnstoCHARsemanticstoavoidconfusionlateron.
Aslinkedinnote144808.1,youcanuseascriptthatupdatesallcolumnsfromalltables:Note313175.1ChangingcolumnstoCHARlengthsemantics.
Typically:

whenusingCsalter/AlterdatabasethecolumnsarechangedtoCHARsemantics(orCLOB)orenlargedinBYTESaftergoingtoAL32UTF8(=RunningCsalterorAlterDatabase)butbeforeimportingtheexported"Convertible/Trunca
whenusingfullexportimportthetablesareprecreatedinthenewdatabaseusingCHARsemantics,CLOBorlargercolumnssizesinBYTESbeforeimportingthedata.
Whenusingfullexport/importthetablescanbecreatedinthenewdatabaseupfrontusingforexampletheFULL=YandCONTENT=METADATA_ONLY(andoptionallySQLFILE)imdpdoptionsorusedbms_metadata(forexample

Theimportutilityusestheexactsemanticsdefinedonthesourcetabledefinitionfromtheexportdumpfile,notfromthesourceortargetdatabaseinit.orasettings.IfthesourcetablesaredefinedwithBYTEsemanticsthentheywillbec
whenimportingintoadatabasethathasNLS_LENGTH_SEMANTICSsettoCHARintheinit.ora/pfile/spfile.
Inotherwords,settingNLS_LENGTH_SEMANTICS=CHARinyourinit.orawillNOTchangeanytabletoCHARsemanticsduringimportifthosetables(!!!)areusingBYTEonthesourceside.
Toknowhowmuchthedataexpandsyoucan:
*Orusethisprocedure:
NotethatwhenusingthecsscanSUPPRESSparameterthisproceduremaygiveincompleteresults(notalltablesornotthecorrectminimalneededdatasize).

Sqlplus/assysdba
SETserveroutputONsize200000
DECLARE
newmaxszNUMBER
BEGIN
FORrecIN
(SELECTDISTINCTu.owner_name,
u.table_name,
u.column_name,
u.column_type,
u.owner_id,
u.table_id,
u.column_id,
u.column_intid
FROMcsmv$errorsu
WHEREu.error_type='EXCEED_SIZE'
ORDERBYu.owner_name,
u.table_name,
u.column_name
)
LOOP
SELECTMAX(cnvsize)
INTOnewmaxsz
FROMcsm$errors
WHEREusr#=rec.owner_id
ANDobj#=rec.table_id
ANDcol#=rec.column_id
ANDintcol#=rec.column_intid
DBMS_OUTPUT.PUT_LINE(rec.owner_name||'.'||rec.table_name||'('||rec.column_name||')'||rec.column_type||''||newmaxsz||'Bytes')
ENDLOOP
END
/
ThiswillgivetheminimalamountofBYTESthecolumnneedstobetoaccommodatetheexpansion.
*OrchecktheCsscanoutput.Youcanfindthatinthe.errfileas"MaxPostConversionDataSize"Forexample,checkinthe.txtfilewichtablehas"Truncation",let'sassumeyouhavetherearowthatsay's:
snipfromtoutf8.txt

[DistributionofConvertible,TruncatedandLossyDatabyTable]
USER.TABLEConvertibleTruncationLossy

...
SCOTT.TESTUTF86960
...
thenlookinthetoutf8.errfilefor"TESTUTF8"untilthe"MaxPostConversionDataSize"isbiggerthenthecolumnsizeforthattable.
snipfromtoutf8.err

User:SCOTT
Table:TESTUTF8
Column:ITEM_NAME
Type:VARCHAR2(80)
NumberofExceptions:6
MaxPostConversionDataSize:81
themaxsizeaftergoingtoAL32UTF8willbe81bytesforthiscolumn.
Csalter/AlterDatabaseCharacterSethasproblemswithfunctionalindexeson/partitionsusingCHARbasedcolumns.Seepoint7).Ifyouhavefunctionalindexes/partitionsyoucanonlychangethosecolumnstoCHARsemantics
tablecolumnscanbechangedtoCHARsemanticsbeforegoingtoAL32UTF8ifrequired.
TruncationinDataDictionaryobjectsisrareandwillbesolvedbyusingthestepsfor"Convertible"DataDictionarydata.

Whileit'stechnicallyonlyneededtotakeactiononthe"Truncation"rowsreportedbyCsscanit'sstillagoodideatoconsiderusingCHARSemanticsforevery"Application"columnorusingexplicitCHARsemanticsdeclarationforvariable
database.

6)Dealingwith"Convertible"data.
hereyouchoosedependingonwhatisrequired/youwanttodo

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

6/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


hereyouchoosedependingonwhatisrequired/youwanttodo
WhenyouwanttouseCsalter/AlterDatabaseCharacterSetandchangethecurrentdatabasegotopoint6a)
Whenyouwanttouse(FULL)export/importintoanewAL32UTF8dbor(FULL)export/importotherAL32UTF8dbtakethe(full)exportnowandgotopoint12).
Onceany"Lossy"or"Truncation"isdealtwith,(full)exp/impintoanewAL32UTF8databasecanbeused.Thiswilltakecareofany"convertible"data.
Whenusingexport/importusingthe"old"Exp/ImptoolstheNLS_LANGsettingissimplyAMERICAN_AMERICA.<sourceNLS_CHARACTERSET>.
Expdp/imdpd(datapump)doesnotusetheNLS_LANGfordataconversion.Note227332.1NLSconsiderationsinImport/ExportFrequentlyAskedQuestions
Therestofthisnoteuntilstep12)willdealonlywithusingCsalter/AlterDatabaseCharacterSetcombinedwithpartialexport/import.

6.a)"Convertible"ApplicationData:

WhenusingCsalter/AlterDatabaseCharacterSetallUser/ApplicationData"Convertible"dataneedstobeexportedandtruncated/deleted.ThismeansALLdatathatislistedas"Convertible"inthe[ApplicationDataConversionSummary]
truncated.
Again,thisisoftenmisunderstood:
*ifthe"Convertible"dataunder[ApplicationDataConversionSummary]isNOTexportedthenCsalterwillNOTrunandfailwithUnrecognizedconvertibledatefoundinscannerresult.
*ifthe"Convertible"dataunder[ApplicationDataConversionSummary]isNOTexportedthenwhenUsing"AlterDatabaseCharacterSet"thisdatawillbeCORRUPTED.
ItisMANDATORYtoexportandtruncate/deleteALL"Convertible"User/ApplicationDatadata.
10gandup:Thiswillgivealistofall"ApplicationData"tableswhohave"Convertible"(oralsoTruncation)andneedtobeexportedandtruncated/deletedbeforeCsaltercanbeused:
Belowselectwillonlygiveall"Convertible"columnsifCAPTURE=Ywasusedinpoint4).
IfyouusedCAPTURE=N(thedefault)thentheresultsetofbelowselectwillNOTlistthe"Convertible"onlythe"Truncation"data(ifitexist).
The.txtfilewillalwayslisttheconvertibleuserdataregardlessofthesettingofCAPTURE.

Sqlplus/assysdba
SELECTDISTINCTz.owner_name
||'.'
||z.table_name
||'('
||z.column_name
||')'
||z.column_type
||''
||z.error_type
||''UserColumns
FROMcsmig.csmv$errorsz
WHEREz.owner_nameNOTIN
(SELECTDISTINCTusernameFROMcsmig.csm$dictusers
)
ORDERBYUserColumns
/
TocheckforconstraintdefinitionsonthetablesbeforeexportingandtruncatingthemNote1019930.6Script:ToreportTableConstraintsorNote779129.1HowToshowallrecursiveconstraintsleadingtoatablecanbeused.
Theremighthoweveralso"OracleProvided"objectsinthislist(Note160861.1OracleCreatedDatabaseUsers:Password,UsageandFiles).

Themostcommonaresampleschema's'HR','OE','SH','PM','IX','BI'and'SCOTT'and/orAPEX(OracleApplicationExpress)/HTMLDB'FLOWS_xxxx'and'APEX_xxxx'objects.Thesampleschemacanbesimplydropped,ifAPEX/HTMLD
removedusingNote558340.1HowtoUninstallOracleHTMLDB/ApplicationExpressfromtheDatabase?.(assaidinpoint2.Cinthisnote).
Alsocommonareobjectsfortheusers'SYSMAN'and/or'PERFSTAT'.

TheseusersareNOTconsideredbyCsaltertobe"DataDictionaryobjects"henceconvertibleCLOBneedalsotobeaddressedforthesecolumns,justlikeany"normal"applicationdata.Fromdatabasepointofviewthereisnoproblemtoe

charactersetchange/importthis"OracleProvided"userdataifthereisno'Truncation'and/or'Lossy'butonly'Convertible'listed.Ofcoursemakesurethatforexamplewhenexporting'SYSMAN'userdatatheDatabaseControlisstoppeda
done.
SYSMANconvertiblecanalsobesolvedbyremovingthedbcontrolregistration,seeNote278100.1HowToDrop,CreateAndRecreateDBControlInA10gDatabase(canalsobeusedinan11gdb)
Whenusingexport/importusingthe"old"Exp/ImptoolstheNLS_LANGsettingissimplyAMERICAN_AMERICA.<sourceNLS_CHARACTERSET>.
Expdp/imdpd(datapump)doesnotusetheNLS_LANGfordataconversion.Note227332.1NLSconsiderationsinImport/ExportFrequentlyAskedQuestions

6.b)"Convertible"datainDataDictionaryobjects:
ThemainchallengewhenusingCsalter/AlterDatabaseCharacterSetis,besidesexportingandtruncatingall"Convertible"User/ApplicationData,mostofthetime"Convertible"datainDataDictionaryobjects.
*For8i/9iALL"Convertible"dataintheDataDictionaryobjectslistedunderthe"[DataDictionaryConversionSummary]"headerinthetoutf8.txtneedstobeaddressed.
*For10gandupyoudonotneedtotakeactionon"convertible"DataDictionaryCLOBdata.ConvertibleCLOBinDataDictionaryobjectsishandledbyCsalter.
ConvertibleCHAR,VARCHAR2andLONGlistedunderthe"[DataDictionaryConversionSummary]"headerinthetoutf8.txthoweverdoneedaction.
10gandup:IfthenextselectgivesNOrowsthereisnoactiontotakeonDataDictionaryobjects,evenifthereis"Convertible"CLOBlistedunderthe"[DataDictionaryConversionSummary]"headerinthetoutf8.txt
Ifitdoesgiverows,seeNote258904.1SolvingConvertibleorLossydatainDataDictionaryobjectsreportedbyCsscanwhenchangingtheNLS_CHARACTERSET

Sqlplus/assysdba
SELECTDISTINCTz.owner_name
||'.'
||z.table_name
||'('
||z.column_name
||')'
||z.column_type
||''
||z.error_type
||''NotHandledDataDictColumns
FROMcsmig.csmv$errorsz
WHEREz.owner_nameIN
(SELECTDISTINCTusernameFROMcsmig.csm$dictusers
)minus
SELECTDISTINCTz.owner_name
||'.'
||z.table_name
||'('
||z.column_name
||')'
||z.column_type
||''
||z.error_type
||''DataDictConvCLob

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

7/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH

||''DataDictConvCLob
FROMcsmig.csmv$errorsz
WHEREz.error_type='CONVERTIBLE'
ANDz.column_type='CLOB'
ANDz.owner_nameIN
(SELECTDISTINCTusernameFROMcsmig.csm$dictusers
)
ORDERBYNotHandledDataDictColumns
/

Note258904.1SolvingConvertibleorLossydatainDataDictionaryobjectsreportedbyCsscanwhenchangingtheNLS_CHARACTERSET
hasabove(andother)selectsthatgivesabetteroverviewthentheCsscan*.txtfileoutputonwhatobjectsneedactionandhowtosolvecommonseen"Convertible"dataforDataDictionarycolumns.
IfthereareDataDictionarycolumnsinyourCsscanoutputthatarenotlistedinNote258904.1pleaselogaSRifyouneedhelp.
IfyoudologaSRaboutwhattodopleaseDOprovidetheoutputofaboveselect.
DoNOTtruncateorexportDataDictionaryobjectsitselfunlessthisissaidtobepossibleinNote258904.1

ThisnotemybeusefultoidentifyOraclecreatedusersinyourdatabaseNote160861.1OracleCreatedDatabaseUsers:Password,UsageandFiles.Thisnotemayalsobeuseful:Note472937.1InformationOnInstalledDatabaseComponent
Toremove"Convertible"outofanIntermedia/OracleTextIndex(afterithasbeenremovedfromthetable)pleaseseeNote176135.1

7)BeforeusingCsalter/AlterDatabaseCharacterSetcheckthedatabasefor:
7.a)PartitionsusingCHARsemantics:
Sqlplus/assysdba
SELECTc.owner,
c.table_name,
c.column_name,
c.data_type,
c.char_length
FROMall_tab_columnsc,
all_tablest
WHEREc.owner=t.owner
ANDc.table_name=t.table_name
ANDc.char_used='C'
ANDt.partitioned='YES'
ANDc.table_nameNOTIN
(SELECTtable_nameFROMall_external_tables
)
ANDc.data_typeIN('VARCHAR2','CHAR')
ORDERBY1,2
/

IfthisselectgivesrowsbackthenthechangetoAL32UTF8willfailwith"ORA14265:datatypeorlengthofatablesubpartitioningcolumnmaynotbechanged"or"ORA14060:datatypeorlengthofatablepartitioningcolumnmaynotb
CHARsemanticsareusedaspartitioningkeyorsubpartitionkeyseenthechangetoAL32UTF8willadapttheactualbytelengthofCHARsemanticcolumns(data_lenghinall_tab_columns).

IftherearecolumnsusingCHARsemanticsusedaspartitioningkeyorsubpartitionkeythepartitionedtablesneedtobeexported,droppedand,afterthechange,imported.AnothersolutionistotemporarilygobacktoBYTEsemanticsfo
AL32UTF8andthengobacktoCHARsemanticsafterwards..
Note330964.1providesmorebackgroundonthisissue.

7.b)Function,DomainorJoinedindexesonCHARsemanticscolumns.
7.b.1)FunctionalordomainindexesoncolumnsusingCHARsemantics
Sqlplus/assysdba
SELECTowner,
index_name,
table_owner,
table_name,
status,
index_type
FROMdba_indexes
WHEREindex_typeIN('DOMAIN','FUNCTIONBASEDNORMAL','FUNCTIONBASEDNORMAL/REV','FUNCTIONBASEDBITMAP')
ANDtable_nameIN
(SELECTUNIQUE(x.table_name)FROMdba_tab_columnsxWHEREx.char_used='C'ANDx.data_typeIN('CHAR','VARCHAR2'))
ORDERBY1,2
/

IfthisgivesrowsbackthenthechangetoAL32UTF8willfailwith"ORA30556:functionalindexisdefinedonthecolumntobemodified"orwith"ORA02262:ORA904occurswhiletypecheckingcolumndefaultvalueexpression".Ifthere
columnsusingCHARsemanticstheindexneedtobedroppedandrecreatedafterthechange.
Notethatadisablewillnotbeenough.TheDDLofallthoseindexescanbefoundusing:

Sqlplus/assysdba
SETLONG2000000
SETpagesize0
EXECUTEdbms_metadata.set_transform_param(dbms_metadata.session_transform,'STORAGE',FALSE)
SELECTdbms_metadata.get_ddl('INDEX',index_name,owner)
FROMdba_indexes
WHEREindex_typeIN('DOMAIN','FUNCTIONBASEDNORMAL','FUNCTIONBASEDNORMAL/REV','FUNCTIONBASEDBITMAP')
ANDtable_nameIN
(SELECTUNIQUE(x.table_name)FROMdba_tab_columnsxWHEREx.char_used='C'ANDx.data_typeIN('CHAR','VARCHAR2'))
EXECUTEdbms_metadata.set_transform_param(dbms_metadata.session_transform,'DEFAULT')

7.b.2)JoinindexesoncolumnsusingCHARsemantics
Sqlplus/assysdba
SELECTowner,
index_name,
table_owner,
table_name,
status,
index_type
FROMdba_indexes
WHEREtable_nameIN

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

8/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


WHEREtable_nameIN
(SELECTUNIQUE(object_name)FROMdba_objectsWHEREobject_idIN
(SELECTUNIQUEobj#FROMsys.col$WHEREproperty='8454440'))
ANDtable_nameIN
(SELECTUNIQUE(table_name)FROMdba_tab_columnsWHEREchar_used='C'ANDdata_typeIN('CHAR','VARCHAR2'))
ORDERBY1,2
/
IfthisgivesrowsbackthenthechangetoAL32UTF8willfailwith"ORA54028:cannotchangetheHIDDEN/VISIBLEpropertyofavirtualcolumn".
IftherearejoinindexesandthosecolumnsareusingCHARsemanticstheindexneedtobedroppedandrecreatedafterthechange.
Notethatadisablewillnotbeenough.
TheDDLofallthoseindexescanbefoundusing:

Sqlplus/assysdba
SETLONG2000000
SETpagesize0
EXECUTEdbms_metadata.set_transform_param(dbms_metadata.session_transform,'STORAGE',FALSE)
SELECTdbms_metadata.get_ddl('INDEX',index_name,owner)
FROMdba_indexes
WHEREtable_nameIN
(SELECTUNIQUE(object_name)FROMdba_objectsWHEREobject_idIN(SELECTUNIQUEobj#FROMsys.col$WHEREproperty='8454440'))
ANDtable_nameIN
(SELECTUNIQUE(x.table_name)FROMdba_tab_columnsxWHEREx.char_used='C'ANDx.data_typeIN('CHAR','VARCHAR2'))
EXECUTEdbms_metadata.set_transform_param(dbms_metadata.session_transform,'DEFAULT')

Thereisabugin11greleasesbefore11.2.0.2(11.2.0.1,11.10.7and11.1.0.6)thatcausesthe"dropindex"commandtonotdropthehiddencolumnsforbitmapjoinindexes,resultinginORA54028duringCsalter,eveniftheindexesa
Theworkaroundistomakeacopyofthedataviaonlineredefinitionanddroppingtheoldtables.Droppingtheoldtableswilldropallcolumnsincludingtheorphanedcolumns

7.c)SYSTIMESTAMPintheDEFAULTvalueclausefortablesusingCHARsemantics.
Sqlplus/assysdba
SETserveroutputON
BEGIN
FORrecIN
(SELECTowner,
table_name,
column_name,
data_default
FROMdba_tab_columns
WHEREchar_used='C'
)
loop
IFupper(rec.data_default)LIKE'%TIMESTAMP%'THEN
dbms_output.put_line(rec.owner||'.'||rec.table_name||'.'||rec.column_name)
ENDIF
ENDloop
END
/
ThiswillgiveORA604erroroccurredatrecursiveSQLlevel%s,ORA1866thedatetimeclassisinvalidduringthechangetoAL32UTF8.
TheworkaroundistotemporarychangeaffectedtablestouseaDEFAULTNULLclauseeg:ALTERTABLEtabMODIFY(col...DEFAULTNULLNOTNULL)
Afterthecharactersetchangethedefaultclausecanberestored.

7.d)ClustersusingCHARsemantics.
Sqlplus/assysdba
SELECTowner,
object_name
FROMall_objects
WHEREobject_type='CLUSTER'
ANDobject_nameIN
(SELECTUNIQUE(table_name)FROMdba_tab_columnsWHEREchar_used='C'
)
ORDERBY1,2
/
Ifthisgivesrowsbackthenthechangewillfailwith"ORA01447:ALTERTABLEdoesnotoperateonclusteredcolumns".Thoseclustersneedtobedroppedandrecreatedafterthechange.

7.e)UnusedcolumnsusingCHARsemantics
Sqlplus/assysdba
SELECTowner,
table_name
FROMdba_unused_col_tabs
WHEREtable_nameIN
(SELECTUNIQUE(table_name)FROMdba_tab_columnsWHEREchar_used='C'
)
ORDERBY1,2
/

UnusedcolumnsusingCHARsemanticswillgiveanORA00604:erroroccurredatrecursiveSQLlevel1withan"ORA00904:"SYS_C00002_09031813:50:03$":invalididentifier".Notethatthe"SYS_C00002_09031813:50:03$"willchangefor
needtobedropped.

ALTERTABLEtable_nameDROPUNUSEDCOLUMNS
/

7.f)CheckthatyouhaveenoughroomtorunCsalterortoimportthe"Convertible"dataagainafterwards.
In10gandupverifyatleastintoutf8.txt/toutf8fin.txtthe"Expansion"columnfoundunder[DatabaseSize]andcheckyouhaveatleast2timestheexpansionlistedforSYSTEMtablespacefree.
ThisisthesizeneededforCsaltertoupdateDataDictionaryCLOB.Otherwiseyouwillseeerrorslike"ORA01691:unabletoextendlobsegmentSYS.SYS_LOB0000058943C00039$$by1598intablespaceSYSTEM"duringCsalter.
Ingeneral(foranyversion)it'sagoodideatocheckthe"Expansion"columnandseethatthereisenoughspaceineachlistedtablespace.
TheExpansioncolumngivesan estimation onhowmuchmoreplaceyouneedinthattablespacewhengoingtothenewcharacterset.

TheTablespaceExpansionfortablespaceXiscalculatedasthegrandtotalofthedifferencesbetweenthebytelengthofastringconvertedtothetargetcharactersetandtheoriginalbytelengthofthisstringoverallstringsscannedintab
Thedistributionofvaluesinblocks,PCTFREE,freeextents,etc.,arenottakenintoaccount.

7.g)Objectsintherecyclebin(10gandup)
Iftherecyclebinwasnotdisabledmakesuretherearenoobjectsintherecyclebin

Sqlplus/assysdba
SELECTOWNER,ORIGINAL_NAME,OBJECT_NAME,TYPEFROMdba_recyclebinORDERBY1,2

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

9/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


SELECTOWNER,ORIGINAL_NAME,OBJECT_NAME,TYPEFROMdba_recyclebinORDERBY1,2
/
Ifthereareobjectsintherecyclebinthenperform

Sqlplus/assysdba
PURGEDBA_RECYCLEBIN
/
Thiswillremoverecyclebinobjects,otherwiseduringCSALTERanORA38301maybeseen.

7.h)Checkifthecompatibleparameterissettoyourbaseversion
Sqlplus/assysdba
shoparametercompatible
Donottrytomigrateforexamplean10gdatabasewithcompatible=9.2

8)Afterany"Lossy"issolved,"Truncation"dataisplannedtobeaddressedand/or"Convertible"exported/truncated/addressedandpoint7)isokru
check.
$csscan\"sys/<syspassword>@<TNSalias>assysdba\"FULL=YTOCHAR=AL32UTF8LOG=TOUTF8FINCAPTURE=YARRAY=1000000PROCESS=2

8.a)For8i/9itheCsscanoutputneedstobe"Changeless"forallCHAR,VARCHAR2,CLOBandLONGdata(DataDictionaryandUser/Applicationdata).
Inordertouse"AlterDatabaseCharacterSet"youneedtoseeinthetoutf8fin.txtfileunder[ScanSummary]thismessage::
Allcharactertypedatainthedatadictionaryremainthesameinthenewcharacterset
Allcharactertypeapplicationdataremainthesameinthenewcharacterset
IfthisisNOTseeninthetoutf8fin.txtthenthismeanssomethingismissedornotallstepsinthisnotearefollowed.IgnoringthisWILLleadtodatacorruption.
Ifthisisseen,thencontinueinstep9)

8.b)For10ganduptheCsscanoutputneedstobe
*"Changeless"forallCHARVARCHAR2,andLONGdata(DataDictionaryandUser/Applicationdata)
*"Changeless"forallUser/ApplicationdataCLOB
*"Changeless"and/or"Convertible"forallDataDictionaryCLOB
AndinordertorunCsalteryouneedtoseeinthetoutf8fin.txtfileunder[ScanSummary]these2messages:
Allcharactertypeapplicationdataremainthesameinthenewcharacterset
andunder[DataDictionaryConversionSummary]thismessage:
ThedatadictionarycanbesafelymigratedusingtheCSALTERscript
YouneedtoseeBOTH,theCsaltermessagealoneisNOTenough.
Notethedifferencebetween"Allcharactertypeapplicationdataremainthesameinthenewcharacterset"and"Allcharactertypeapplicationdataareconvertibletothenewcharacterset".
Ifyousee"Allcharactertypeapplicationdataareconvertibletothenewcharacterset"thenCsalterwillNOTwork.

IfyourunCsalterwithouttheseconditionsmetthenyouwillseemessageslike"Unrecognizedconvertibledatafoundinscannerresult"or"Exceptionaldatafoundinscannerresult"and"CheckingorConvertin
successfullyNodatabase(national)charactersetwillbealtered"intheCsalteroutput.
CsalterwillNOTworkandsay"CSALTERfinishedunsuccessfully."
BeforeyoucanrunCsalteryouneed
*tohaveabove2(BOTH!)messagesinthe.txtfile.
*tohavethatFULL=Yrunbeencompletedinthe7dayspriortorunningCsalter.SoyoucanonlyrunCsalterinthe7daysfollowingthe"Clean"FULL=Yscan.
*tobesurethesessionrunningCsalteristheONLYsessionconnectedtothedatabase,otherwiseCsalterwillgivethiswarning'Sorryonlyonesessionisallowedtorunthisscript'.

9)SummaryofstepsneededtouseAlterDatabaseCharacterSet/Csalter:
9.a)For9iandlower:

9.a.1)Exportallthe"Convertible"User/ApplicationDatadata(makesurethatthecharactersetpartoftheNLS_LANGissettothecurrentdatabasecharactersetduringtheexportsession)
9.a.2)Ifyouhave"convertible"dataforDataDictionary(sys)objectslikeSYS.METASTYLESHEET,SYS.RULE$orSYS.JOB$thenfollowthefollowingnoteforthoseobjects:Note258904.1ConvertibledatainDataDictionary:Workarounds
9.a.3)Truncatetheexported"Convertible"User/ApplicationData.
9.a.4)Runcsscanagainwiththesyntaxofpoint8)toverifyyouonlyhave"changeless"DataDictionaryandUser/ApplicationDataleft
9.a.5)IfthisnowreportsonlyChangelessdata
Inordertouse"AlterDatabaseCharacterSet"youneedtoseeinthetoutf8fin.txtfileunder[ScanSummary]thismessage::

Allcharactertypedatainthedatadictionaryremainthesameinthenewcharacterset
Allcharactertypeapplicationdataremainthesameinthenewcharacterset
IfthisisNOTseeninthetoutf8fin.txtthenthismeanssomethingismissedornotallstepsinthisnotearefollowed.
IgnoringthisWILLleadtodatacorruption.
thenproceedtostep10.a),otherwisedothesameagainfortherowsyou'vemissedout.
9.a.6)Adaptanycolumnsifneededtoavoid"Truncation"
9.a.7)Importtheexporteddataagain.

9.b)For10gandup:
9.b.1)Exportallthe"Convertible"User/ApplicationData(makesurethatthecharactersetpartoftheNLS_LANGissettothecurrentdatabasecharactersetduringtheexportsession)
9.b.2)FixanynonCLOBDataDictionary"Convertible"usingNote258904.1,
All"9ionly"fixesinNote258904.1ConvertibledatainDataDictionary:WorkaroundswhenchangingcharactersetshouldNOTbedonein10gandupthosearesysCLOBobjectshandledbyCsalter.
9.b.3)Truncatetheexported"Convertible"User/ApplicationDatatables.
9.b.4)Runcsscanwiththesyntaxofpoint8)toverifyyouonlyhave"convertible"CLOBintheDataDictionaryandallotherdatais"Changeless".
WhenusingCsscanin10gandupthetoutf8.txtortoutf8fin.txtneedtocontainthisbeforedoingstep9):

ThedatadictionarycanbesafelymigratedusingtheCSALTERscript
and

Allcharactertypeapplicationdataremainthesameinthenewcharacterset
IfthisisNOTseeninthetoutf8fin.txtthenCsalterwillNOTworkandthismeanssomethingismissedornotallstepsinthisnotearefollowed.
9.b.5)Ifthisisnowcorrectthenproceedtostep10.b),otherwisedothesameagainfortherowsyou'vemissedout.
9.b.6)Adaptanycolumnsifneededtoavoid"Truncation"
9.b.7)Importtheexporteddataagain.

10)RunningCsalter(10gand11g)orAlterDatabaseCharacterSet(8iand9i)
Pleaseperformabackupofthedatabase.Checkthebackup.Doublecheckthebackup.

10.a)Thestepsfor8iand9iONLY

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

10/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


Donotdosteps10.a.1)and10.a.2)ona10gor11gorhighersystem.For10gandupgotostep10.b)
Shutdownthelistenerandanyapplicationthatconnectslocallytothedatabase.
ThereshouldbeonlyONEconnectionthedatabaseduringtheWHOLEtimeandthat'sthesqlplussessionwhereyoudothechange.
Thisselect

SELECTsid,serial#,username,status,osuser,machine,process,programFROMv$sessionWHEREusernameISNOTNULL
shouldonlygiveONErowyoursqlplusconnection.
10.a.1)MakesurethePARALLEL_SERVER(8i)andCLUSTER_DATABASEparameteraresettofalseoritisnotsetatall.WhenusingRACyouwillneedtostartthedatabaseinsingleinstancewithCLUSTER_DATABASE=FALSE

Sqlplus/assysdba
shoparameterCLUSTER_DATABASE
shoparameterPARALLEL_SERVER
10.a.2)Executethefollowingcommandsinsqlplusconnectedas"/ASSYSDBA":

Sqlplus/assysdba
SPOOLNswitch.log
SHUTDOWNIMMEDIATE
STARTUPMOUNT
ALTERSYSTEMENABLERESTRICTEDSESSION
ALTERSYSTEMSETJOB_QUEUE_PROCESSES=0
ALTERSYSTEMSETAQ_TM_PROCESSES=0
ALTERDATABASEOPEN
ALTERDATABASECHARACTERSETINTERNAL_USEAL32UTF8
SHUTDOWNIMMEDIATE
YouNEEDtorestartthedatabasebeforedoingANYoperationonthisdatabase
exitthissessionnowdonotusethesessionthatdidalterdatabaseforotheroperations
EXIT
reconnecttothedatabaseandstartthedatabase
Sqlplus/assysdba
STARTUP
in8iyouneedtodothestartup/shutdown2times
SHUTDOWN
STARTUP

Analterdatabasetakestypicallyonlyafewminutesorless,itdependsonthenumberofcolumnsinthedatabase,nottheamountofdata.WithouttheINTERNAL_USEyougetaORA12712:newcharactersetmustbeasupersetofold
10.a.3)RestorethePARALLEL_SERVER(8i)andCLUSTER_DATABASEparameterifnecessaryandstartthedatabase.ForRACstarttheotherinstances.
WARNINGWARNINGWARNING
DoNEVERuse"INTERNAL_USE"unlessyoudidfollowtheguidelinesSTEPBYSTEPhereinthisnoteandyouhaveagoodideawhatyouaredoing.
DoNEVERuse"INTERNAL_USE"to"fix"displayproblems,butfollowNote:179133.1ThecorrectNLS_LANGinaWindowsEnvironmentorNote:264157.1ThecorrectNLS_LANGsettinginUnixEnvironments
IfyouusetheINTERNAL_USEclauseonadatabasewherethereisdatalistedasconvertiblewithoutexportingthatdatathenthedatawillbecorruptedbychangingthedatabasecharacterset!
gotopoint10.c),donotdopoint10.b)

10.b)Thestepsforversion10gand11g
Csalter.plbneedstobeusedwithin7daysaftertheCsscanrun,otherwiseyouwillgeta'TheCSSCANresulthasexpired'message.
Shutdownthelistenerandanyapplicationthatconnectslocallytothedatabase.
ThereshouldbeonlyONEconnectionthedatabaseduringtheWHOLEtimeandthat'sthesqlplussessionwherethechangeisdone.
Thisselect

SELECTsid,serial#,username,status,osuser,machine,process,programFROMv$sessionWHEREusernameISNOTNULL
shouldonlygiveONErowyoursqlplusconnection.IfmorethenonesessionisconnectedCsalterwillfailandreport"Sorryonlyonesessionisallowedtorunthisscript".
IfyouareusingRACyouwillneedtostartthedatabaseinsingleinstancewithCLUSTER_DATABASE=FALSE
Runinsqlplusconnectedas"/ASSYSDBA":

Sqlplus/assysdba
MakesuretheCLUSTER_DATABASEparameterisset
tofalseoritisnotsetatall.
IfyouareusingRACyouwillneedtostartthedatabaseinsingleinstance
withCLUSTER_DATABASE=FALSE
shoparameterCLUSTER_DATABASE
ifyouareusingspfilenotethe
shoparameterjob_queue_processes
shoparameteraq_tm_processes
(thisisBug6005344fixedin11g)
thendo
shutdown
startuprestrict
SPOOLNswitch.log
PURGEDBA_RECYCLEBIN
/
dothisaltersystemoryoumightruninto"ORA22839:DirectupdatesonSYS_NCcolumnsaredisallowed"
Thisisonlyneededin11.1.0.6,fixedin11.1.0.7,notapplicableto10.2orlower
ALTERSYSTEMSETEVENTS'22838TRACENAMECONTEXTLEVEL1,FOREVER'
thenrunCsalter.plb:
@?/rdbms/admin/csalter.plb
Csalterwillaksconfirmationdonotcopypastethewholeactionsononetime
sampleCsalteroutput:
3rowscreated.

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

11/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


...
ThisscriptwillupdatethecontentoftheOracleDataDictionary.
Pleaseensureyouhaveafullbackupbeforeinitiatingthisprocedure.
Wouldyouliketoproceed(Y/N)?y
old6:if(UPPER('&conf')<>'Y')then
New6:if(UPPER('y')<>'Y')then
Checkingdatavalidility...
beginconvertingsystemobjects
PL/SQLproceduresuccessfullycompleted.
Alterthedatabasecharacterset...
CSALTERoperationcompleted,pleaserestartdatabase
PL/SQLproceduresuccessfullycompleted.
...
Proceduredropped.
ifyouareusingspfilethenyouneedtoalso
ALTERSYSTEMSETjob_queue_processes=<originalvalue>SCOPE=BOTH
ALTERSYSTEMSETaq_tm_processes=<originalvalue>SCOPE=BOTH
SHUTDOWNIMMEDIATE
YouNEEDtorestartthedatabasebeforedoingANYoperationonthisdatabase
exitthissessionnow.donotusethesessionwhereCsalterwasrunnedforotheroperations.
EXIT
reconnecttothedatabaseandstartthedatabase
Sqlplus/assysdba
STARTUP

andthedatabasewillbeAL32UTF8.
Note:in10.1csalterisaskingfor"Entervaluefor1:".

Wouldyouliketoproceed?(Y/N)?Y
old5:if(UPPER('&conf')<>'Y')then
new5:if(UPPER('Y')<>'Y')then
Entervaluefor1:
>simplyhitenter.
goto10.c)

10.c)ChecktheCsalter/alterdatabaseoutputandthealert.logforerrors,someCsaltermessagesdoNOThaveanORAnumber.

10gandup:ifyouseeseemessagesintheCsalteroutputlike"Unrecognizedconvertibledatafoundinscannerresult"or"CheckingorConvertingphrasedidnotfinishsuccessfullyNodatabase(national)charactersetwillbealtered"th
andyoumissedsomestepsinthisnote.
Allversions:IfduringCsalter/alterdatabaseyouseeerrorsafterthe

Alterthedatabasecharacterset...
messageinthealert.logorduringalterdatabasecommand(8ior9i)/Csalterlikeforexample:

ORA41400:Bindcharacterset(31)doesnotmatchdatabasecharacterset(873)
Note:theCharactersetbindmaydiffer(=othernumberthan31):
oranothererrorlike

ORA00604:erroroccurredatrecursiveSQLlevel1
or
ORA604signalledduring:ALTERDATABASECHARACTERSETAL32UTF8...
thentheNLS_CHARACTERSETisNOTchanged(fully)afterrunningCsalter/alterdatabase
Mostcommoncausesare:
*oranotherprocesswasconnectedtothedatabaseAFTERCsalter/aleterdatabasewasstarted,soCsalter/alterdatabasedidnotsawthesecondconnectionatstartup.DoNOTconnectwithANYsessionduringCsalter/alterdatabase.
*orthechecksinstep7ofthisnotewhereNOTdone
*orsomeotherproblemoccured.
IferrorsareseenthentheNLS_CHARACTERSETwillNOTbechangedsuccesfully.
CheckyourAlert.logfortheexacterrorthatwasseen,removethecauseandrunCsalteroralterdatabase(9i)again.
IfnothingobviousisfoundtobewrongpleaselogaSRandprovidethelastcsscanfiles,theFULLoutputofCsalteroralterdatabase,thealert.logandanytracefilesgenerated.
YoucandoanadditionalcheckafterthechangeoftheNLS_CHARACTERSET

Sqlplus/assysdba
selectdistinct(nls_charset_name(charsetid))CHARACTERSET,
decode(type#,1,decode(charsetform,1,'VARCHAR2',2,'NVARCHAR2','UNKNOWN'),
9,decode(charsetform,1,'VARCHAR',2,'NCHARVARYING','UNKNOWN'),
96,decode(charsetform,1,'CHAR',2,'NCHAR','UNKNOWN'),
8,decode(charsetform,1,'LONG','UNKNOWN'),
112,decode(charsetform,1,'CLOB',2,'NCLOB','UNKNOWN'))TYPES_USED_IN
fromsys.col$wherecharsetformin(1,2)andtype#in(1,8,9,96,112)
orderbyCHARACTERSET,TYPES_USED_IN
/
thisshouldgive7rows,oneforeachdatatypeand2charactersets:theNLS_CHARACTERSETandNLS_NCHAR_CHARACTERSET.

exampleofcorrectoutputforaAL32UTF8NLS_CHARACTERSETandAL16UTF16NLS_NCHAR_CHARACTERSETdatabase:
CHARACTERSETTYPES_USED_IN

AL32UTF8CHAR
AL32UTF8CLOB
AL32UTF8LONG
AL32UTF8VARCHAR2
AL16UF16NCHAR
AL16UF16NCLOB

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

12/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH


AL16UF16NCLOB
AL16UF16NVARCHAR2
Ifthisselectreturnsmorethan7rows(forexample2differentcharactersetsforVARCHAR2)thenthereissomethingwrongandyouwillhaveerrorsinthealert.logduringtheconversion.

11)ReloadthedatapumppackagesafterachangetoAL32UTF8in10gandup.
For10gorupthedatapumppackagesneedtobereloadedafteraconversiontoAL32UTF8.Note430221.1HowToReloadDatapumpUtilityEXPDP/IMPDP
Insomecasesexp(theoriginalexporttool)failsin10gafterchangingtoAL32UTF8.pleaseseeNote339938.1FullExportFrom10.2.0.1AbortsWithEXP56ORA932(InconsistentDatatypes)EXP0

12)Importtheexporteddata.
NotethatifyouhadintheCsscandoneinpoint4)ONLY"Changeless"andNO"Convertible"(thisisnotoftenseen)thenthereisnodatatoimportwhenusingCsalter/Alterdatabase.

12.a)WhenusingCsalter/AlterdatabasetogotoAL32UTF8andtherewas"Truncation"datainthecsscandoneinpoint4:

TruncationdataisalwaysALSO"Convertible",it's"Convertible"datathatneedsactionbeforeyoucanimportthisagain.Iftherewas"Truncation"thentypicallythisishandledbyprecreatingthetablesusingCHARsemanticsorenlargedc
databasetoAL32UTF8usingCsalter/Alterdatabaseandbeforestartingtheimport.
NotethatsimplysettingNLS_LENGTH_SEMANTICS=CHARintheinit.orawillNOTworktogotoCHARsemantics.
Oncethemeasuresforsolvingthe"Truncation"areinplaceyoucanthenimportthe"Truncation/Convertible"data.
SettheparameterBLANK_TRIMMING=TRUEtoavoidtheproblemdocumentedinNote779526.1CSSCANdoesnotdetectdatatruncationforCHARdatatypeORA12899whenimporting
UsetheIGNORE=YparameterforimportheTABLE_EXISTS_ACTION=TRUNCATEoptionforImpdptoimportthedataintotheprecreatedtables.

ImporttheexporteddatabackintothenowAL32UTF8database,whenusingexport/importusingthe"old"Exp/ImptoolstheNLS_LANGsettingissimplyAMERICAN_AMERICA.<sourceNLS_CHARACTERSET>ORAMERICAN_AMERICA
Expdp/imdpddoesnotusetheNLS_LANGfordataconversion.
Oncethedataisimportedgotostep13.

12.b)Whenusing(Full)export/importtogotoanew/otherAL32UTF8databaseandtherewas"Truncation"datainthecsscandoneinpoint4:

TruncationdataisalwaysALSO"Convertible",it's"Convertible"datathatneedsactionbeforeyoucanimportthisagain.Iftherewas"Truncation"thentypicallythisishandledbyprecreatingthetablesusingCHARsemanticsorenlargedc
newAL32UTF8andbeforestartingtheimport.
NotethatsimplysettingNLS_LENGTH_SEMANTICS=CHARintheinit.orawillNOTworktogotoCHARsemantics.
Oncethemeasuresforsolvingthe"Truncation"areinplaceyoucanthenimportthe"Truncation/Convertible"data.

CreateanewAL32UTF8databaseifneededandsettheinit.oraparameterBLANK_TRIMMING=TRUEtoavoidtheproblemdocumentedinNote779526.1CSSCANdoesnotdetectdatatruncationforCHARdatatypeORA12899whenimpo
UsetheIGNORE=YparameterforimportheTABLE_EXISTS_ACTION=TRUNCATEoptionforImpdptoimportthedataintotheprecreatedtables.

ImporttheexporteddataintothenewAL32UTF8database,whenusingexport/importusingthe"old"Exp/ImptoolstheNLS_LANGsettingissimplyAMERICAN_AMERICA.<sourceNLS_CHARACTERSET>ORAMERICAN_AMERICA.AL32UT
Expdp/imdpddoesnotusetheNLS_LANGfordataconversion.
Oncethedataisimportedgotostep13.

12.c)WhenusingCsalter/AlterdatabasetogotoAL32UTF8andtherewasNO"Truncation"data,only"Convertible"and"Changeless"inthecsscandoneinpoint4:
Settheinit.oraparameterBLANK_TRIMMING=TRUEtoavoidtheproblemdocumentedinNote779526.1CSSCANdoesnotdetectdatatruncationforCHARdatatypeORA12899whenimporting

ImporttheexporteddatabackintothenowAL32UTF8database,whenusingexport/importusingthe"old"Exp/ImptoolstheNLS_LANGsettingissimplyAMERICAN_AMERICA.<sourceNLS_CHARACTERSET>ORAMERICAN_AMERICA
Expdp/imdpddoesnotusetheNLS_LANGfordataconversion.
Oncethedataisimportedgotostep13.

12.d)Whenusing(full)export/importtogotoanew/otherAL32UTF8databaseandtherewasNO"Truncation"data,only"Convertible"and"Changeless"inthecsscand

CreateanewAL32UTF8databaseifneededandsettheinit.oraparameterBLANK_TRIMMING=TRUEtoavoidtheproblemdocumentedinNote779526.1CSSCANdoesnotdetectdatatruncationforCHARdatatypeORA12899whenimpo

ImporttheexporteddataintothenewAL32UTF8database,whenusingexport/importusingthe"old"Exp/ImptoolstheNLS_LANGsettingissimplyAMERICAN_AMERICA.<sourceNLS_CHARACTERSET>ORAMERICAN_AMERICA.AL32UT
Expdp/imdpddoesnotusetheNLS_LANGfordataconversion.
Oncethedataisimportedgotostep13.

13)Checkyourdataandfinalthings:
UseacorrectlyconfiguredclientorOracleSQLDeveloper/iSqlplusandverifyyoudata.Note788156.1AL32UTF8/UTF8(Unicode)DatabaseCharacterSetImplications.
ForRACrestoretheCLUSTER_DATABASEparameter,removetheBLANK_TRIMMING=TRUEparameterifneededandrestarttheinstance(s).
TheCsmigusercanalsobedropped.

Sqlplus/assysdba
SQL>dropusercsmigcascade
IfyoudidnotuseCHARsemanticsforallCHARandVARCHAR2columnsandpl/sqlvariablesitmightbeanideatoconsiderthis.
Checkforinvalidobjectsasaresultoftheexp/impoperations.

Sqlplus/assysdba
SELECTowner,
object_name,
object_type,
status
FROMdba_objects
WHEREstatus='INVALID'
/Ifthereareanyinvalidobjectsrunutlrp.sql
SQL>@?/rdbms/admin/utlrp.sql
Itisalsohighlyrecommendedtocollectnewstatsforyourdatabase

Sqlplus/assysdba
wherexisnrofcpucores
EXECDBMS_STATS.GATHER_DATABASE_STATS(DEGREE=>'x')

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

13/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

14/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

15/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH

Posted by Amaranath at 06:37


Recommend this on Google

No comments:
Post a Comment

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

16/17

6/5/2014

Amr Blog: NLS_CHARACTERSET for BOTH ARABIC and FRENCH

Enteryourcomment...

Commentas:

GoogleAccount

Publish

Preview

Newer Post

Home

Older Post

Subscribe to: Post Comments (Atom)

Simple template. Powered by Blogger.

http://amr12c.blogspot.com/2013/07/nlscharacterset-for-both-arabic-and.html

17/17

También podría gustarte