天天看點

使用者之間imp的問題

今天同僚說申請了一個從生産導出的dump檔案,需要導入測試庫進行測試。

之前做的基本都是本庫導出,本庫導入的操作,例如:imp test/***@test tables=tbl_fuel file=H:\dev\data\tbl_fuel.dmp ignore=y這樣的指令操作。

今天的情況是從一個庫的使用者導出dump,然後導入到另外一個庫的使用者中。

導出:

exp p_x/**  FILE=tables.dmp TABLES=e.pre_ldp,e.tbl_flight log=tables.log rows=y

幾種錯誤的導入:

imp test/***@test tables=(tbl_a,tbl_b) file=tables.dmp log=test.log full=y

提示:

IMP-00024: Only one mode (TABLES, FROMUSER, or FULL) can be specified

TABLES、FROMUSER和FULL參數隻能使用一個。

imp test/***@test file=tables.dmp log=test.log ignore=n

Warning: the objects were exported by P_X, not by you

import done in ZHS16CGB231280 character set and AL16UTF16 NCHAR character set

import server uses ZHS16GBK character set (possible charset conversion)

export client uses ZHS16GBK character set (possible charset conversion)

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

IMP-00031: Must specify FULL=Y or provide FROMUSER/TOUSER or TABLES arguments

IMP-00000: Import terminated unsuccessfully

FULL=Y、FROMUSER/TOUSER和TABLES參數必須指定其中之一。

imp test/***@test file=tables.dmp

log=test.log ignore=n fromuser=user ouser=test

IMP-00034: Warning: FromUser "USER" not found in export file

Import terminated successfully with warnings.

說明From User "USER"不包含在dump檔案中。但通過這種方式可以找到是哪個使用者使用exp導出的這份dump檔案。

imp test/***@test file=tables.dmp log=test.log ignore=n tables=tbl_a

. importing P_X's objects into TEST

IMP-00033: Warning: Table "TBL_A" not found in export file

說明TBL_A表并不在導出的dump中,個人認為,因為這裡未使用FROMUSER這些參數,預設就是dump中包含的資料是從本地test使用者的,是以這會報錯。

log=test.log ignore=n fromuser=e touser=test(未建立表結構)

imp test/***@test file=tables.dmp log=test.log

ignore=y fromuser=e touser=test(已建立表結構)

這裡表示删除了表後,ignore=n,dump的來源是e這個schema或使用者,導入到這個測試test使用者下。

當然,由于test使用者沒有導出庫的一些角色,是以如下這些權限操作可能會失敗,但不影響使用這些測試。

IMP-00017: following statement failed with ORACLE error 1917:

 "GRANT UPDATE ON "TBL_A" TO "B_E""

參數:

fromuser具體指定那個使用者下的對象需要導入,是以如果這裡使用p_x,會報錯,因為表不在p_x使用者下。

touser具體指定導入那個使用者,該參數必須跟fromuser一起使用。

show在螢幕顯示檔案内容,具體不會做導入操作。

ignore忽略導入過程中建立對象的錯誤(確定資料能夠導入),但不會忽略寫入資料的錯誤(如導入的資料跟目前表裡的資料有違反唯一性限制的錯誤)。

commit該參數為Y時,導入的過程會送出資料行,若buffer設定得太小,則會過去頻繁的送出資料,對性能有一定的影響。使用commit還有一個好處,就是做測試資料導入時,如果有些錯誤未插入資料庫,使用commit後會将符合的記錄commit送出,不會導緻整個導入操作復原,因為畢竟是做測試,多一些少一些資料問題不是很大。

full導入整個檔案。

tables導入表名清單,多個表名,逗号分隔。

rows該參數為Y的時候将導入資料,預設是導入資料。但出于某種原因可以将該參數設定成N即不導入資料行。