開發(fā)中經(jīng)常遇到復(fù)制數(shù)據(jù)的需求蓝翰,比如有開發(fā)環(huán)境光绕,測試環(huán)境,模擬生產(chǎn)環(huán)境等畜份;又或者同一項(xiàng)目服務(wù)不同的客戶诞帐。
比如現(xiàn)有schema user1,將它的數(shù)據(jù)復(fù)制到 schema user2 中爆雹。
第一步導(dǎo)出數(shù)據(jù)
exp user1/password@127.0.0.1:1521/orcl?OWNER=user1 FILE=/tmp/user1_data.dmp
這一步一般沒有問題停蕉,然后將數(shù)據(jù)導(dǎo)入到 user2。
第二步驟導(dǎo)入數(shù)據(jù)
imp user2/user2@127.0.0.1:1521/orcl fromuser=user1 touser=user2 file=/tmp/user1_data.dmp;
請使用 user2 作為登錄用戶钙态,如果使用 user1慧起,則需要 dba 權(quán)限:
IMP-00007: must be a DBA to import objects to another user's account
還可能遇到如下問題:
EXP-00091: Exporting questionable statistics.
這是服務(wù)器端編碼和客戶端編碼不一致造成的,可將客戶端編碼設(shè)置為何服務(wù)器端一致册倒,如下:
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
--------------------------------------------------------------------------------
AMERICAN_CHINA.AL32UTF8
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@~]$ export NLS_LANG=AMERICAN_CHINA.AL32UTF8?