Recently, when I was working on a project, I encountered a problem. During the select Operation on the Oracle 11g database of Windows 2003 system, the result was "dependent on ", at that time, the O & M personnel did not know much about oracle, So they found me. I checked the character set between the server and the client and found that the server is zhs16gbk and the client is american_america.we8iso8858p1, when I modified the character set of the client and the server, the problem was solved.
The following is a technical document I have prepared to explain how to learn oracle in the future.
Environment:
Windows 2003 32 system, Oracle 11g Database
1. Connect to oracle 11g for windows 2003
- C :\>Sqlplus/as sysdba
-
- SQL * Plus: Release 11.2.0.1.0 Production on Monday May 21 15:03:29 2012
-
- Copyright (c) 1982,201 0, Oracle. All rights reserved.
-
-
- Connect:
- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
2. view the character set of the Client
- SQL> select userenv('language') from dual;
-
- USERENV('LANGUAGE')
- ----------------------------------------------------
- AMERICAN_AMERICA.ZHS16GBK
3. view the server Character Set
- SQL> set linesize 100
- SQL> col parameter for a40
- SQL> col value for a40
- SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET%%';
-
- PARAMETER VALUE
- ---------------------------------------- ----------------------------------------
- NLS_CHARACTERSET ZHS16GBK
- NLS_NCHAR_CHARACTERSET AL16UTF16
We can see that the character set of the client and server is consistent, both of which are ZHS16GBK. 4. Create a dl_char table
- SQL>Create table dl_char (name varchar2 (20 ));
-
- The table has been created.
5. Insert data
- SQL>Insert into dl_char values ('character set garbled Ps ');
-
- One row has been created.
6. select query
- SQL>Select * from dl_char;
-
- NAME
- --------------------
- Character Set garbled
As you can see, it is displayed as the value I just entered 7. Change the character set of the client.
- C:\>SET NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
8. log on again.
- C:\>sqlplus / as sysdba
-
- SQL*Plus: Release 11.2.0.1.0 Production on Mon May 21 15:06:55 2012
-
- Copyright (c) 1982, 2010, Oracle. All rights reserved.
-
-
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options