Oracle Chinese characters are garbled or quoted string not properly terminated occurs when executing sql using sqlplus.

There are many ways to deal with garbled characters on the Internet, but they are not detailed or explained. Some problems cannot be solved by modifying them.

First of all, the garbled characters are related to the connection terminal, Oracle server, and server environment variable encoding settings.

1. First, the environment variables must be configured under user variables: ~/.bash_profile 

2. Use select userenv('language') from dual; to view the oracle encoding

   For example, here is: AMERICAN_AMERICA.ZHS16GBK

3.vim ~/.bash_profile configure the environment variable export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK,

   Then source ~/.bash_profile takes effect

4. After confirming that the encoding is GBK, change the encoding of the connected terminal, for example, change xshell to GBK

5. Open sqlplus and execute the ddl or dml statement, preferably the field comment statement of ddl, to see if quoted string not properly terminated appears.

   For example: comment on column user.user_no is 'user number';

6. If it does not appear, it is successful, and then use sqlplus to execute the sql script file to check whether it is successful. The encoding of the sql script file must also be GBK.

  Everything is subject to the encoding of the Oracle server.

7. When there is a problem in step 6, check whether the first 5 parts are correct, or try changing the LANG encoding to GBK.

Guess you like

Origin blog.csdn.net/Qensq/article/details/107410085