ORACLE數(shù)據(jù)庫同步

1、oracle導(dǎo)入導(dǎo)出方法

使用工具導(dǎo)入

1、使用plsql導(dǎo)入

oracle導(dǎo)出方法

1、查詢結(jié)果集

2、選擇導(dǎo)出格式

通常導(dǎo)出格式為sql(導(dǎo)入效率較慢)、excel、csv(導(dǎo)入相對前兩個較快)格式

[圖片上傳失敗...(image-ffc7f0-1664188703357)]

2、使用Navicat 導(dǎo)入

注意:該方式的數(shù)據(jù)傳輸是以源數(shù)據(jù)庫中的數(shù)據(jù)為主,覆蓋目標(biāo)數(shù)據(jù)庫中的數(shù)據(jù)。

1、選擇工具中的數(shù)據(jù)傳輸

2、將源數(shù)據(jù)庫、目標(biāo)庫連接上,點擊下一步

3、選中數(shù)據(jù)庫對象中某張或多張需要傳輸?shù)谋?。點擊開始按鈕,開始傳輸。

3、命令行導(dǎo)入導(dǎo)出(格式:dmp)

不同數(shù)據(jù)庫之間數(shù)據(jù)庫同步

  1. 導(dǎo)出整個數(shù)據(jù)庫實例中的所有數(shù)據(jù)

    登錄超級管理員

    exp system/密碼@10.13.37.46:1521/agj2j0 file=C:\TEST.dmp full=y;

  2. 導(dǎo)出某用戶下的所有數(shù)據(jù)

    exp system/密碼@10.13.37..46:1521/agj2j0 file=C:\TEST.DMP OWNER=(用戶名,用戶名 )

  3. 導(dǎo)出指定單張表的所有數(shù)據(jù)

exp 用戶名/密碼@10.13.37.46:1521/agj2j0 file=C:\TEST.DMP tables=(表名,表名)

導(dǎo)入

imp 用戶名/密碼@10.13.37146:1521/agj2j0 file="C:\TEST.DMP" full=y ignore=y full=y :

ignore = y :忽略錯誤

復(fù)制表結(jié)構(gòu)及其數(shù)據(jù):

相同數(shù)據(jù)庫之間數(shù)據(jù)庫同步

select * from newtable as select * from oldtable where 1=1;  --復(fù)制表結(jié)構(gòu)以及數(shù)據(jù)按where條件查詢出的數(shù)據(jù)
select * from newtable as select * from oldtable where 1=2;  --只復(fù)制表結(jié)構(gòu)
create table table_name_new like table_name_old; --只復(fù)制表結(jié)構(gòu)
insert into table_name_new select * from table_name_old;--只復(fù)制表數(shù)據(jù)(兩張表結(jié)構(gòu)相同)
insert into table_name_new(column1,column2...) select column1,column2... from table_name_old;--只復(fù)制表數(shù)據(jù)(兩張表結(jié)果不相同)

導(dǎo)出分為:導(dǎo)出表/導(dǎo)出方案/導(dǎo)出數(shù)據(jù)庫

userid:用于指定執(zhí)行導(dǎo)出操作的用戶名,口令,連接字符串
tables:用于指定執(zhí)行導(dǎo)出操作的表
owner: 用于指定執(zhí)行導(dǎo)出操作的方案(指定用戶:該用戶下所有的表結(jié)構(gòu)\索引\約束)
full=y:用于指定執(zhí)行導(dǎo)出操作的數(shù)據(jù)庫
inctype: 用于指定執(zhí)行導(dǎo)出操作的增量類型
rows: 用于指定執(zhí)行導(dǎo)出操作是否要導(dǎo)出表中的數(shù)據(jù)
file: 用于指定導(dǎo)出文件名

1 表

1.導(dǎo)出單張表
exp userid=scott/tiger@oral tables=(emp,dept) file=d:\e1.dmp

table:指定數(shù)據(jù)表
2. 導(dǎo)出整張表
exp userid=scott/tiger@oral tables=(emp) file=d:\e4.dmp direct=y
3.只導(dǎo)出表結(jié)構(gòu)或只導(dǎo)出表數(shù)據(jù)
exp userid=scott/tiger@oral tables=(emp) file=d:\e3.dmp rows=n
rows:用于指定執(zhí)行導(dǎo)出操作是否要導(dǎo)出表中的數(shù)據(jù) y:是 n:不是

2方案(用戶)

exp userid=scott/tiger@orcl owner=scott file=d:\scott.dmp

3 數(shù)據(jù)庫

exp userid=system/manager@orcl full=y inctype=complete file=d:\all.dmp

導(dǎo)入 :導(dǎo)入也分為導(dǎo)入表,導(dǎo)入方案,導(dǎo)入數(shù)據(jù)庫三種方式。

imp常用的選項有
userid:用于指定執(zhí)行導(dǎo)入操作的用戶名,口令,連接字符串
tables:用于指定執(zhí)行導(dǎo)入操作的表
formuser****:用于指定源用戶
touser:用于指定目標(biāo)用戶

file:用于指定導(dǎo)入文件名
full=y:用于指定執(zhí)行導(dǎo)入整個文件
inctype:用于指定執(zhí)行導(dǎo)入操作的增量類型
rows:指定是否要導(dǎo)入表行(數(shù)據(jù))
ignore:如果表存在,則只導(dǎo)入數(shù)據(jù)

導(dǎo)入表
\1. 導(dǎo)入自己的表

imp userid=scott/tiger@orcl tables=(emp) file=d:\xx.dmp

\2. 導(dǎo)入表到其它用戶
要求該用戶具有dba的權(quán)限,或是imp_full_database

imp userid=system/system賬戶的密碼@orcl tables=(emp) file=d:\xx.dmp touser=scott

\3. 導(dǎo)入表的結(jié)構(gòu)
只導(dǎo)入表的結(jié)構(gòu)而不導(dǎo)入數(shù)據(jù)

imp userid=scott/tiger@orcl tables=(emp) file=d:\xx.dmp rows=n

\4. 導(dǎo)入數(shù)據(jù)
如果對象(如比表)已經(jīng)存在可以只導(dǎo)入表的數(shù)據(jù)

imp userid=scott/tiger@orcl tables=(emp) file=d:\xx.dmp ignore=y

導(dǎo)入方案 (用戶)
導(dǎo)入方案是指使用import工具將文件中的對象和數(shù)據(jù)導(dǎo)入到一個或是多個方案中。如果要導(dǎo)入其它方案,要求該用戶具有dba的權(quán)限,或者imp_full_database
1. 導(dǎo)入自身的方案

imp userid=scott/tiger file=d:\xxx.dmp

2. 導(dǎo)入其它方案
要求該用戶具有dba的權(quán)限

imp userid=system/system賬戶的密碼 file=d:\xxx.dmp fromuser=導(dǎo)出dmp文件的用名戶 touser=要導(dǎo)入dmp文件的用戶名 ignore=y

導(dǎo)入數(shù)據(jù)庫
在默認(rèn)情況下,當(dāng)導(dǎo)入數(shù)據(jù)庫時,會導(dǎo)入所有對象結(jié)構(gòu)和數(shù)據(jù),案例如下:

imp userid=system/system賬戶的密碼full=y file=d:\xxx.dmp

小注:當(dāng)“fromuser=導(dǎo)出dmp文件的用名AA”在本地沒有的的時候(即要導(dǎo)入dmp文件的數(shù)據(jù)庫中沒有這個用戶名)==》需要新建這個用戶AA,新建過程:Oracle創(chuàng)建表空間、創(chuàng)建用戶以及授權(quán)

導(dǎo)出本部:

exp userid=agjh/agj2j0@10.13.37.46:1521/agj2j0 tables=(test_one) file=D:\學(xué)習(xí)文檔整理\ORACLE\檢化驗數(shù)據(jù) 庫同步數(shù)據(jù) rows=n

導(dǎo)入鲅魚圈

imp userid=agjh/agj4j0@10.91.4.15:1521/agj4j0 tables=(test_one)  file=D:\學(xué)習(xí)文檔整理\ORACLE\檢化驗數(shù)據(jù) 庫同步數(shù)據(jù).DMP rows=n
``





?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容