天天看點

linux中導入導出oracle資料庫

一 導出

1.在Linnux伺服器上如果不是oracle使用者,則要切換到oracle使用者。

   指令如下:

    su - oracle

2.exp導出工具

    exp導出工具将資料庫中資料備份壓縮成一個二進制系統檔案,可以在不同OS間遷移。

    exp導出工具又分為互動式指令行方式和非互動式指令行方式 .

    (1)互動式指令行方式

    exp username(使用者名)/password(密碼)@servicename(資料庫服務名)

    例如

    $exp  ttt/[email protected]

    Enter array fetch buffer size: 4096 > 回車

    Export file: expdat.dmp > t.dmp  導出的檔案名 

       (1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 3

       1:整個資料庫  2:所有的使用者,schema  3:所有的表

    Export table data (yes/no): yes > no

    是否導出表中的資料

    Compress extents (yes/no): yes > 回車

    是否壓縮

   Export done in US7ASCII character set and UTF8 NCHAR character set

   server uses AL32UTF8 character set (possible charset conversion)

   About to export specified tables via Conventional Path ...

   Table(T) or Partition(T:P) to be exported: (RETURN to quit) > t  要導出的表名

   . . exporting table                       t

   Table(T) or Partition(T:P) to be exported: (RETURN to quit) >要導出的表名n

   Table(T) or Partition(T:P) to be exported: (RETURN to quit) > 回車

   Export terminated successfully without warnings. 

(2)互動式指令行方式

   exp username/[email protected]_name file=/home/oracle/databasename.dmp

         username:使用者名

         password:密碼

         service_name:資料庫的服務名

         file:要導出資料庫檔案的路徑

 二 導入

     1.在要導入的oracle資料庫上建立相應的使用者,隻有擁有IMP_FULL_DATABASE和DBA權限的使用者才能做整個資料庫導入。

      create user username identified by password

      grant dba to username

     2.導入前Linux伺服器切換到oracle使用者

         su - oracle

     3.imp導入工具

       導入工具imp也分互動式和非互動式

      (1)互動式指令行方式

      $ imp

      Username: username

      Password:  password

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

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

      Import data only (yes/no): no >

      是否隻導入資料

      Import file: expdat.dmp > /t/t.dmp

      導入資料庫檔案的路徑

      Enter insert buffer size (minimum is 8192) 30720>

      輸入插入緩沖區大小(最小為 8192 )

      Export file created by EXPORT:V10.02.01 via conventional path

      import done in ZHS16GBK character set and AL16UTF16 NCHAR character set

      export client uses US7ASCII character set (possible charset conversion)

      export server uses UTF8 NCHAR character set (possible ncharset conversion)

      List contents of import file only (yes/no): no >

      隻列出導入檔案的内容

      Ignore create error due to object existence (yes/no): no > yes

      由于對象已存在, 忽略建立錯誤

      Import grants (yes/no): yes >

      導入權限

      Import table data (yes/no): yes >

      導入表資料

      Import entire export file (yes/no): no > yes

      導入整個導出檔案

      . importing XXXXXXobjects into XXXXXX

      . . importing table              "t"       2775 rows imported

      Import terminated successfully with warnings. 

       (2)互動式指令行方式

       $ imp usrname/password file = t.dmp full=y 

三 注意事項

     1.oracle資料庫導出時老是遇到一錯誤.ora-12641:驗證服務無法初始化

        這個問題的标準代碼應該為 tns-12641(ora-12500到ora-12699的錯誤,應該是tns-12500到tns-12699).

        網絡問題,從網絡方面着手 

        将sqlnet.ora檔案中的SQLNET.AUTHENTICATION_SERVICES = (TNS)

        修改為SQLNET.AUTHENTICATION_SERVICES = (none)