Oracle 查看imp匯出檔案中字元集

來源:互聯網
上載者:User

我們在exp匯入的時候,經常會有警告字元不一致的問題。下面來看看在imp/exp匯入匯出的時候,nls_lang這個參數到底應該怎麼來配置。

Oracle推薦在執行exp的時候nls_lang配置與database nls_character一致,這樣不會出現字元轉換的問題,能提高exp的效率。查看database nls_character

  1. SQL> select value from nls_database_parameters where parameter='NLS_CHARACTERSET'; 
  2.  
  3. VALUE 
  4. ------------------------------ 
  5. ZHS16GBK 

  我們這裡只做查看已經匯出的exp檔案的字元集。

  1. $ echo $NLS_LANG 
  2.  
  3. $  
  4. $ exp userid=scott/oracle file='/tmp/scott.dmp' log='/tmp/scott.log' 
  5.  
  6. Export: Release 11.2.0.3.0 - Production on Thu Aug 30 13:07:22 2012 
  7.  
  8. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  9.  
  10.  
  11. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  12. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  13. Export done in US7ASCII character set and AL16UTF16 NCHAR character set 
  14. server uses ZHS16GBK character set (possible charset conversion) 
  15. . exporting pre-schema procedural objects and actions 
  16. . exporting foreign function library names for user SCOTT  
  17. . exporting PUBLIC type synonyms 
  18. . exporting private type synonyms 
  19. . exporting object type definitions for user SCOTT  
  20. About to export SCOTT's objects ... 
  21. . exporting database links 
  22. . exporting sequence numbers 
  23. . exporting cluster definitions 
  24. . about to export SCOTT's tables via Conventional Path ... 
  25. . . exporting table                          BONUS          0 rows exported 
  26. EXP-00091: Exporting questionable statistics. 
  27. . . exporting table                           DEPT          4 rows exported 
  28. EXP-00091: Exporting questionable statistics. 
  29. EXP-00091: Exporting questionable statistics. 
  30. . . exporting table                            EMP         14 rows exported 
  31. EXP-00091: Exporting questionable statistics. 
  32. EXP-00091: Exporting questionable statistics. 
  33. . . exporting table                       SALGRADE          5 rows exported 
  34. EXP-00091: Exporting questionable statistics. 
  35. . exporting synonyms 
  36. . exporting views 
  37. . exporting stored procedures 
  38. . exporting operators 
  39. . exporting referential integrity constraints 
  40. . exporting triggers 
  41. . exporting indextypes 
  42. . exporting bitmap, functional and extensible indexes 
  43. . exporting posttables actions 
  44. . exporting materialized views 
  45. . exporting snapshot logs 
  46. . exporting job queues 
  47. . exporting refresh groups and children 
  48. . exporting dimensions 
  49. . exporting post-schema procedural objects and actions 
  50. . exporting statistics 
  51. Export terminated successfully with warnings. 

   從上面提示可以看到database的字元集是ZHS16GBK,而我的client的nls_lang中的client字元集是US7ASCII。

   下面是查看已經匯出的/tmp/scott.dmp檔案的字元集

  1. $ imp userid=scott/oracle file='/tmp/scott.dmp' show=yes             
  2.  
  3. Import: Release 11.2.0.3.0 - Production on Thu Aug 30 13:07:58 2012 
  4.  
  5. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  6.  
  7.  
  8. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  9. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  10.  
  11. Export file created by EXPORT:V11.02.00 via conventional path 
  12. import done in US7ASCII character set and AL16UTF16 NCHAR character set 
  13. import server uses ZHS16GBK character set (possible charset conversion) 

import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)

import done這行表示的client 的字元集是US7ASCII,匯入匯出端的字元集是相同的。

import server這行表示匯入的資料庫的字元集是ZHS16GBK,由於字元集不一樣,所以會出現字元集的轉換。

當exp client與imp client不一樣的時候會出現下面的提示:

  1. $ export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK 
  2. $ echo $NLS_LANG 
  3. AMERICAN_AMERICA.ZHS16GBK 
  1. $ imp userid=scott/oracle file='/tmp/scott.dmp' show=yes 
  2.  
  3. Import: Release 11.2.0.3.0 - Production on Thu Aug 30 13:11:53 2012 
  4.  
  5. Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. 
  6.  
  7.  
  8. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  9. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  10.  
  11. Export file created by EXPORT:V11.02.00 via conventional path 
  12. import done in ZHS16GBK character set and AL16UTF16 NCHAR character set 
  13. export client uses US7ASCII character set (possible charset conversion) 

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
export client uses US7ASCII character set (possible charset conversion)

export client這行表示匯出client的字元集是US7ASCII。

更詳細的見官方文檔:NLS considerations in Import/Export - Frequently Asked Questions [ID 227332.1]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.