從Export DMP檔案看匯出字符集(下)

realkid4發表於2015-07-03

 

下面我們看一下在Little-Endian下的情況是如何的。

 

3Little-Endian作業系統

 

下面我們來試驗一下Little-Endian作業系統環境。

 

 

[oracle@localhost ~]$ uname -a

Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

 

 

Linux平臺上,依然使用不指定NLS_LANG引數進行匯出。

 

 

[oracle@localhost ~]$ exp \"/ as sysdba\" owner=scott file=scott.dmp

 

Export: Release 11.2.0.4.0 - Production on Wed Jul 1 18:33:38 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export done in US7ASCII character set and AL16UTF16 NCHAR character set

server uses AL32UTF8 character set (possible charset conversion)

 

About to export specified users ...

. exporting pre-schema procedural objects and actions

. exporting foreign function library names for user SCOTT

. exporting PUBLIC type synonyms

. exporting private type synonyms

. exporting object type definitions for user SCOTT

About to export SCOTT's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export SCOTT's tables via Conventional Path ...

. . exporting table                          BONUS          0 rows exported

EXP-00091: Exporting questionable statistics.

. . exporting table                           DEPT          5 rows exported

EXP-00091: Exporting questionable statistics.

(篇幅原因,有省略……

Export terminated successfully with warnings.

 

 

在未指定NLS_LANG引數的情況下,Oracle選擇了US4ASCII字符集作為預設匯出方式,進行了AL32UTF8US4ASCII格式轉換。

 

 

[oracle@localhost ~]$ cat scott.dmp | od -x | head

0000000 0003 4501 5058 524f 3a54 3156 2e31 3230

0000020 302e 0a30 5344 5359 520a 5355 5245 0a53

0000040 3138 3239 300a 370a 0a32 0a30 0100 6903

0000060 d007 0100 0000 0000 0000 0000 0900 2000

0000100 2020 2020 2020 2020 2020 2020 2020 2020

*

0000140 2020 2020 2020 2020 5720 6465 4a20 6c75

0000160 3120 3120 3a38 3333 333a 2038 3032 3531

0000200 6373 746f 2e74 6d64 0070 0000 0000 0000

0000220 0000 0000 0000 0000 0000 0000 0000 0000

 

 

Little EndianBig EndIan最大的區別在於字元順序上,如果是Little Endian,起始檔案頭結構常為xx03的十六進位制結構。原來定義的第二、三位,變成了第一、第四位數字。結果依然是0001,對應Little Endian下的US7ASCII字符集合。

 

下面看一下指定NLS_LANG環境變數方法。

 

 

[oracle@localhost ~]$ export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

[oracle@localhost ~]$ exp \"/ as sysdba\" owner=scott file=scott_set.dmp

 

Export: Release 11.2.0.4.0 - Production on Wed Jul 1 18:35:31 2015

 

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

 

 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

 

About to export specified users ...

. exporting pre-schema procedural objects and actions

. exporting foreign function library names for user SCOTT

. exporting PUBLIC type synonyms

. exporting private type synonyms

. exporting object type definitions for user SCOTT

About to export SCOTT's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export SCOTT's tables via Conventional Path ...

. . exporting table                          BONUS          0 rows exported

(篇幅原因,有省略……

Export terminated successfully without warnings.

 

 

檢視檔案頭資訊,對應位置:

 

 

[oracle@localhost ~]$ cat scott_set.dmp | od -x | head

0000000 0303 4569 5058 524f 3a54 3156 2e31 3230

0000020 302e 0a30 5344 5359 520a 5355 5245 0a53

0000040 3138 3239 300a 370a 0a32 0a30 6903 6903

0000060 d007 0100 0000 0000 0000 0000 0d00 2000

0000100 2020 2020 2020 2020 2020 2020 2020 2020

*

0000140 2020 2020 2020 2020 5720 6465 4a20 6c75

0000160 3120 3120 3a38 3533 333a 2031 3032 3531

0000200 6373 746f 5f74 6573 2e74 6d64 0070 0000

0000220 0000 0000 0000 0000 0000 0000 0000 0000

 

 

對應第一和第四位置上為0x0369,是AL32UTF8字符集型別。

 

4、結論

 

使用Exp/Imp在當前的技術環境下,最大的優勢是客戶端操作模式,雖然也容易引起一些問題。很多操作人員是不被允許直接訪問到資料庫伺服器使用DataPump的。

 

應該說,DataPump應該是提供給DBA和管理員的大資料規模備份還原、遷移工具。Exp/Imp在開發團隊中,特別是中小資料環境下,還有一些適應的空間。使用Exp/Imp過程中,字符集匹配、版本相容是兩個必須注意的問題。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17203031/viewspace-1721217/,如需轉載,請註明出處,否則將追究法律責任。

相關文章