Preface:
After the table into the database, find a lot of garbage, and the original data in the original database is no problem to find a lot of information point of view, found that the problem may be the character set, after the inspection process, the problem has been resolved, the authors note of:
oracle database common character coding format ZHS16GBK, the following record is to replace the character set of practical operation:
[oracle@woitumi-197 dbs]$ sqlplus / as sysdba
Start the database:
SQL > the Startup
SQL>shutdown immediate;
SQL>STARTUP MOUNT;
SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;
SQL>ALTER DATABASE OPEN;
SQL>ALTER DATABASE CHARACTER SET ZHS16GBK;
Then two things can occur:
AT 1 RA-Line ERROR 12721: Operation OTHER CAN not the when the Execute the Active Sessions are
1, if the above error, use the following methods to modify, use INTERNAL_USE can skip the check superset appear:
SQL>ALTER DATABASE CHARACTER SET INTERNAL_USE ZHS16GBK;
2, the results of error, suggesting that the new character set must be a superset of old character set.
12712-ORA: MUST BE SET A new new Character a superset of Old Character SET
RROR AT Line. 1:
need cast:
>ALTER DATABASE character set INTERNAL_USE ZHS16GBK;
In both cases the problem I encountered in the implementation of the relevant commands for the final step:
>shutdown immediate;
>STARTUP;
Attachment:
When the database backup file import,
1. oracel server -side character set ;
2. oracle remote connection tools character set ;
3. Export character set dmp file database.
These three must be the same data after the operation, it will not appear garbled
Query method:
Query oracle server-side character set
There are many ways to find out oracle server-side character sets, more intuitive method of inquiry was the following that :
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK
SQL>select userenv(‘language’) from dual;
AMERICAN _ AMERICA. ZHS16GBK
How to check the character set dmp file
With the oracle derived exp tool dmp file also contains the character set information, of dmp file 2 and 3 bytes of the record character set dmp file. If dmp file is small, such as only a few tens of M or M, can use UltraEdit open (hexadecimal ), read the first 2 of 3 bytes of content, such as 0354, and the following sql isolated characters corresponding to its set :
SQL> select nls_charset_name(to_number('0354','xxxx')) from dual;
ZHS16GBK
如果dmp文件很大,比如有2G以上(这也是最常见的情况),用文本编辑器打开很慢或者完全打不开,可以用以下命令(在linux主机上):
cat exp.dmp |od -x|head -1|awk '{print $2 $3}'|cut -c 3-6