1.創(chuàng)建表空間

--刪除用戶bxuser

drop user bxuser cascade;
--刪除表空間bxuser
DROP TABLESPACE bxuser INCLUDING CONTENTS AND DATAFILES;
--創(chuàng)建表空間bxuser   自動(dòng)擴(kuò)展存儲(chǔ)空間
create tablespace bxbackup
logging
datafile 'E:\oracletablespace\zjbx.dbf'
size 32m
autoextend on
next 32m maxsize unlimited
extent management local;
--創(chuàng)建用戶bxuser,密碼bxuser
create user bxbackup identified by bxbackup default tablespace bxbackup
--授予權(quán)限
grant resource,connect,dba to bxbackup

--cmd導(dǎo)入數(shù)據(jù)
imp bxbackup/bxbackup@//109.102.10.2:1521/orcl log=E:\bxuser.log file=E:\linshi\bxBF201709262015.dmp buffer=50000 fromuser=bxuser touser=bxbackup

 --11導(dǎo)出到10

expdp zjbxdev/zjbxdev@139.199.7.38:1521/orcl dumpfile=test.dmp owner=zjbxdev version=10.2.0.1.0

 

2.數(shù)據(jù)導(dǎo)入導(dǎo)出

cmd

imp命令導(dǎo)入數(shù)據(jù):
imp username/password@SID file=XXX.dmp fromuser=XXX touser=XXX tables=(XXX,XXX)
其中
fromuser指對(duì)方數(shù)據(jù)庫(kù)用戶名,
touser指你的數(shù)據(jù)庫(kù)的用戶名;

fromuser若為多個(gè)表空間的話,使用()將其括起來(lái):fromuser=(a,b);
touser參數(shù)仿fromuser參數(shù);
若只導(dǎo)入一部分表,使用tables參數(shù),用()括起要導(dǎo)入的表;如果想全部導(dǎo)入,不需要指定tables參數(shù)
full=y,是導(dǎo)入文件中全部?jī)?nèi)容,有可能有多個(gè)用戶的內(nèi)容。
如果你聯(lián)接的用戶默認(rèn)使用的表空間設(shè)置成system,則導(dǎo)入文件的內(nèi)容會(huì)導(dǎo)到system上。
使用full=y可以不需要先在目標(biāo)服務(wù)器上創(chuàng)建用戶
有的表已經(jīng)存在,然后它就報(bào)錯(cuò),對(duì)該表就不進(jìn)行導(dǎo)入。 在后面加上 ignore=y 就可以了。

例:
imp fanhua/fanhua@localhost/oracle file=E:\Project\hrhb\dlhx.dmp fromuser=dlhx touser=fanhua ignore=y

數(shù)據(jù)導(dǎo)出:
1 將數(shù)據(jù)庫(kù)TEST完全導(dǎo)出,用戶名system 密碼manager 導(dǎo)出到D:\daochu.dmp中
exp system/manager@TEST file=d:\daochu.dmp full=y

2 將數(shù)據(jù)庫(kù)中system用戶與sys用戶的表導(dǎo)出
exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)

3 將數(shù)據(jù)庫(kù)中的表inner_notify、notify_staff_relat導(dǎo)出
exp aichannel/aichannel@TESTDB2 file= d:\data\newsmgnt.dmp tables=

(inner_notify,notify_staff_relat)