循序渐进Oracle:数据库的字符集和字符集文件
122 阅读 2020-07-29 11:25:02 上传
以下文章来源于 语料数据库
导读:本文来自『墨天轮』专栏“循序渐进Oralcle”(https://www.modb.pro/topic/6289,复制到浏览器中打开或者点击“阅读原文”),介绍《循序渐进Oracle》第三章的3.1-3.4节:字符集的基本知识、数据库的字符集、字符集文件及字符支持、NLS_LANG的设置与影响、导入导出及字符转换。
CREATE DATABASE "eygle"
MAXINSTANCES 8 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100
DATAFILE SIZE 300M AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE SIZE 120M AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE SIZE 20M AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE SIZE 200M AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
……
ZHS16CGB231280 CGB2312-80 16-bit Simplified Chinese MB, ASCII
ZHS16GBK GBK 16-bit Simplified Chinese MB, ASCII, UDC
SQL> select dump('盖') from dual;
DUMP('盖')
---------------------
Typ=96 Len=2: 184,199
SQL> select concat(to_char(184,'xx'),to_char(199,'xx')) from dual;
CONCAT
------
b8 c7
SQL> select to_number('b8c7','xxxxxx') from dual;
TO_NUMBER('B8C7','XXXXXX')
--------------------------
47303
SQL> select chr(47303) from dual;
CH
--
盖
C:\oracle\10.2.0\nls\data>dir lx20354.nlb
2006-10-10 14:52 477,772 lx20354.nlb
C:\oracle\10.2.0\nls\data>move lx20354.nlb lx20354.nlb.b
C:\oracle\10.2.0\nls\data>net start oracleserviceeygle
OracleServiceEYGLE 服务正在启动 ...
OracleServiceEYGLE 服务已经启动成功。
C:\oracle\10.2.0\nls\data>sqlplus "/ as sysdba"
Error 5 initializing SQL*Plus
NLS initialization error
C:\oracle\10.2.0\nls\data>set nls_lang=AMERICAN_AMERICA.US7ASCII
C:\oracle\10.2.0\nls\data>sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.3.0 - Production on Mon Jun 18 17:10:46 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
ERROR:
ORA-03113: end-of-file on communication channel
[oracle@wapdb ~]$ strace -o sqlplus.log sqlplus /nolog
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Sep 27 10:23:52 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL> exit
[oracle@wapdb ~]$ grep nls sqlplus.log
open("/opt/oracle/product/11.1.0/nls/data/lx1boot.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx00001.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx20354.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx10035.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx20001.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx40001.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx10001.nlb", O_RDONLY) = 8
E:\>set NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
E:\>sqlplus "/ as sysdba"
连接到:Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> select sysdate from dual;
SYSDATE
----------
01-11月-03
已选择 1 行。
E:\>set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
E:\>sqlplus "/ as sysdba"
Connected to:Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> select sysdate from dual;
SYSDATE
---------
01-NOV-03
1 row selected.
[oracle@wapdb ~]$ env|grep NLS
NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
[oracle@wapdb ~]$ export NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
[oracle@wapdb ~]$ strace -o exp.log exp
Export: Release 11.1.0.6.0 - Production on 星期一 9月 27 10:39:05 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Username:
Password:
[oracle@wapdb ~]$ grep nls exp.log
open("/opt/oracle/product/11.1.0/nls/data/lx1boot.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx00023.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx20354.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx10035.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx20001.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx00001.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx10001.nlb", O_RDONLY) = 3
open("/opt/oracle/product/11.1.0/nls/data/lx207d0.nlb", O_RDONLY) = 9
E:\nls2>set NLS_LANG=AMERICAN_AMERICA.US7ASCII
E:\nls2>e:\oracle\ora8i\bin\imp eygle/eygle file=Sus7ascii-Cus7ascii-exp817.dmp fromuser=eygle touser=eygle tables=test
Import: Release 8.1.7.1.1 - Production on Fri Nov 7 00:59:22 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.1.1 - Production
With the Partitioning option
JServer Release 8.1.7.1.1 - Production
Export file created by EXPORT:V08.01.07 via conventional path
import done in US7ASCII character set and ZHS16GBK NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)
export server uses UTF8 NCHAR character set (possible ncharset conversion)
. . importing table "TEST" 2 rows imported
Import terminated successfully without warnings.
E:\nls2>set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
E:\nls2>e:\oracle\ora8i\bin\imp eygle/eygle file=Sus7ascii-Cus7ascii-exp817.dmp fromuser=eygle touser=eygle
Import: Release 8.1.7.1.1 - Production on Fri Nov 7 00:38:55 2003
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.1.1 - Production
With the Partitioning option
JServer Release 8.1.7.1.1 - Production
IMP-00016: required character set conversion (type 1 to 852) not supported
IMP-00000: Import terminated unsuccessfully
Export file created by EXPORT:V08.01.07 via conventional path
import done in US7ASCII character set and ZHS16GBK NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)
export server uses UTF8 NCHAR character set (possible ncharset conversion)
. . importing table "TEST" 2 rows imported
Import terminated successfully without warnings.
E:\nls2>sqlplus eygle/eygle
Connected to:Oracle8i Enterprise Edition Release 8.1.7.1.1 - Production
With the Partitioning option
JServer Release 8.1.7.1.1 - Production
SQL> select * from test;
NAME
--------------------
2bJT
test
相关工具
点赞
收藏
表情
图片
附件