–查字符集
select userenv(‘language’) from dual;
1.在服务器端插入生僻字,服务器端正常可显示:
但工具客户端显示乱码:
2.在客户端工具插入生僻字,服务器和客户端都显示乱码:
SQL> conn / as sysdba
Connected.
SQL> create user jyc identified by jyc;
User created.
SQL> grant dba to jyc;
Grant succeeded.
SQL> conn jyc/jyc
Connected.
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
SQL> create table t(id int,name varchar2(20));
Table created.
SQL> insert into t values(1,'草');
1 row created.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
SQL> insert into t values(2,'龘');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
SQL
SQL>
SQL> insert into t values(3,'㼆');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
3 㼆
SQL> desc t;
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(38)
NAME VARCHAR2(20)
SQL> insert into t values(4,'䶮');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
3 㼆
4 䶮
SQL> insert into t values(5,'䓬');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
3 㼆
4 䶮
5 䓬
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
3 㼆
4 䶮
5 䓬
SQL> insert into t values(6,'㯎');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
3 㼆
4 䶮
5 䓬
6 㯎
6 rows selected.
SQL> ALTER TABLE t add CONSTRAINT PK_t PRIMARY KEY (id);
Table altered.
SQL> select INDEX_NAME,INDEX_TYPE,TABLE_NAME,UNIQUENESS from dba_indexes where table_name='T';
INDEX_NAME INDEX_TYPE
------------------------------ ---------------------------
TABLE_NAME UNIQUENES
------------------------------ ---------
PK_T NORMAL
T UNIQUE
SQL> insert into t values(7,'㱔');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
3 㼆
4 䶮
5 䓬
6 㯎
7 㱔
7 rows selected.
SQL>
SQL> insert into t values(8,'𣆳');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
ID NAME
---------- --------------------
1 草
2 龘
3 㼆
4 䶮
5 䓬
6 㯎
7 㱔
8 𣆳
8 rows selected.
根本解决办法:
数据库字符集应该使用AL32UTF8