Oracle導出導出有兩中方式:一、利用exp imp導出導入;二、利用Oracel數(shù)據(jù)泵expdp impdp導出導入。
成都創(chuàng)新互聯(lián)公司是專業(yè)的江干網(wǎng)站建設公司,江干接單;提供成都做網(wǎng)站、網(wǎng)站設計,網(wǎng)頁設計,網(wǎng)站設計,建網(wǎng)站,PHP網(wǎng)站建設等專業(yè)做網(wǎng)站服務;采用PHP框架,可快速的進行江干網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
一、利用exp imp導出導入
exp imp 語法如下:
exp:
1) 將數(shù)據(jù)庫orcl完全導出
exp system/manager@orcl file=d:\orcl_bak.dmp full=y
2) 將數(shù)據(jù)庫中system用戶的表導出
exp system/manager@orcl file=d:\system_bak.dmp owner=system
3) 將數(shù)據(jù)庫中表table1,table2導出
exp system/manager@orcl file=d:\table_bak.dmp tables=(table1,table2)
4) 將數(shù)據(jù)庫中的表customer中的字段mobile以"139"開頭的數(shù)據(jù)導出
exp system/manager@orcl file=d:\mobile_bak.dmp tables=customer query=\"where mobile like '139%' \"
imp:
1) 將備份文件bak.dmp導出數(shù)據(jù)庫
imp system/manager@orcl file=d:\bak.dmp
如果數(shù)據(jù)表中表已經(jīng)存在,會提示錯誤,在后面加上ignore=y就可以了。
2) 將備份文件bak.dmp中的表table1導入
imp system/manager@orcl file=d:\bak.dmp tables=(table1)
exp imp導出導入數(shù)據(jù)方式的好處是只要你本地安裝了Oracle客戶端,你就可以將服務器中的數(shù)據(jù)導出到你本地計算機。同樣也可以將dmp文件從你本地導入到服務器數(shù)據(jù)庫中。但是這種方式在Oracle11g版本中會出現(xiàn)一個問題:不能導出空表。Oracle11g新增了一個參數(shù)deferred_segment_creation,含義是段延遲創(chuàng)建,默認是true。當你新建了一張表,并且沒用向其中插入數(shù)據(jù)時,這個表不會立即分配segment。
解決辦法:
1、設置deferred_segment_creation參數(shù)為false后,無論是空表,還是非空表,都分配segment。
在sqlplus中,執(zhí)行如下命令:
SQLalter system set deferred_segment_creation=false;
查看:
SQLshow parameter deferred_segment_creation;
該值設置后,只對后面新增的表起作用,對之前建立的空表不起作用,并且注意要重啟數(shù)據(jù)庫讓參數(shù)生效。
2、使用 ALLOCATE EXTEN
使用 ALLOCATE EXTEN可以為數(shù)據(jù)庫對象分配Extent,語法如下:
alter table table_name allocate extent
構(gòu)建對空表分配空間的SQL命令:
SQLselect 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
批量生成要修改的語句。
然后執(zhí)行這些修改語句,對所有空表分配空間。
此時用exp命令,可將包括空表在內(nèi)的所有表導出。
二、利用expdp impdp導出導入
在Oracle10g中exp imp被重新設計為Oracle Data Pump(保留了原有的 exp imp工具)
數(shù)據(jù)泵與傳統(tǒng)導出導入的區(qū)別;
1) exp和imp是客戶端工具,他們既可以在客戶端使用,也可以在服務端使用。
2) expdp和impdp是服務端工具,只能在Oracle服務端使用。
3) imp只適用于exp導出文件,impdp只適用于expdp導出文件。
expdp導出數(shù)據(jù):
1、為輸出路徑建立一個數(shù)據(jù)庫的directory對象。
create or replace directory dumpdir as 'd:\';
可以通過:select * from dba_directories;查看。
2、給將要進行數(shù)據(jù)導出的用戶授權(quán)訪問。
grant read,write on directory dumpdir to test_expdp;
3、將數(shù)據(jù)導出
expdp test_expdp/test_expdp directory=dumpdir dumpfile=test_expdp_bak.dmp logfile=test_expdp_bak.log schemas=test_expdp
注意:這句話在cmd窗口中運行,并且最后不要加分號,否則會提示錯誤。因為這句話是操作系統(tǒng)命令而不是SQL。
impdp導入數(shù)據(jù):
1、給將要進行數(shù)據(jù)導入的用戶授權(quán)訪問。
grant read,write on directory dumpdir to test_impdp;
2、將數(shù)據(jù)導入
impdp test_impdp/impdp directory=dumpdir dumpfile=test_expdp_bak.dmp remap_schema=test_expdp:test_impdp
1、使用plsql連接上數(shù)據(jù)庫,展開【Tables】菜單項,下面出現(xiàn)的就是數(shù)據(jù)庫表。
2、在數(shù)據(jù)庫表tblTest上面點擊鼠標右鍵,選擇【Query data】,此項的目的是查詢這張數(shù)據(jù)庫表的數(shù)據(jù)。
3、點擊完成【Query data】之后,右側(cè)會出現(xiàn)一個SQL語句的窗口,默認有一條【select * from 表名】的sql語句,下方還有一個列表,展示這張表中的已有數(shù)據(jù)。
4、然后寫一條insert插入的SQL語句,寫完之后,選中這條SQL,點擊左上角的【次輪狀】圖標,然后,SQL語句下方會出現(xiàn)【1 row inserted in xx seconds】,表示語句執(zhí)行成功。此時數(shù)據(jù)還沒有真正寫入數(shù)據(jù)庫 insert插入sql格式:insert into 表名(字段1, 字段2, 字段n) values(值1, 值2, 值n)。
5、在Oracle數(shù)據(jù)庫中,對數(shù)據(jù)的變更還需要點擊【Commit】按鈕,也就是左上角向下箭頭的圖標,如果不點擊這個按鈕,數(shù)據(jù)其實不會真正存入數(shù)據(jù)庫。點擊【Commit】按鈕后,會彈出一個Confirm窗口,此時點擊【Yes】就將數(shù)據(jù)寫入數(shù)據(jù)庫,點擊【No】則不提交到數(shù)據(jù)庫。
可用圖形界面或者命令導入:
圖形界面需要借助第三方工具plsql,方法如下:
1、登錄到要導入的數(shù)據(jù)庫及用戶。
2、依次點擊“工具”——“導入表”。
3、上方選擇“oracle導入”,下方找到.dmp的文件,然后點擊“導入”等待完成即可。
命令導入:
1、win鍵+R鍵,進入命令提示符。
2、進到.dmp文件所在文件夾:
3、輸入如下命令:
imp?被導入用戶名/密碼@實例名?file=文件名.dmp?log=日志.dmp?fromuser=導出用戶?touser=導入用戶
輸入后按回車鍵,等待導入完成即可。
說明:第三點中中文部分,請根據(jù)實際情況填寫。
我給你一些數(shù)據(jù)庫常用的導入導出命令吧:\x0d\x0a該命令在“開始菜單運行CMD”中執(zhí)行\(zhòng)x0d\x0a一、數(shù)據(jù)導出(exp.exe)\x0d\x0a1、將數(shù)據(jù)庫orcl完全導出,用戶名system,密碼accp,導出到d:\daochu.dmp文件中\(zhòng)x0d\x0aexp system/accp@orcl file=d:\daochu.dmp full=y\x0d\x0a\x0d\x0a2、將數(shù)據(jù)庫orcl中scott用戶的對象導出\x0d\x0aexp scott/accp@orcl file=d:\daochu.dmp owner=(scott)\x0d\x0a\x0d\x0a3、將數(shù)據(jù)庫orcl中的scott用戶的表emp、dept導出\x0d\x0aexp scott/accp@orcl file= d:\daochu.dmp tables=(emp,dept)\x0d\x0a\x0d\x0a4、將數(shù)據(jù)庫orcl中的表空間testSpace導出\x0d\x0aexp system/accp@orcl file=d:\daochu.dmp tablespaces=(testSpace)\x0d\x0a\x0d\x0a二、數(shù)據(jù)導入(imp.exe)\x0d\x0a1、將d:\daochu.dmp 中的數(shù)據(jù)導入 orcl數(shù)據(jù)庫中。\x0d\x0aimp system/accp@orcl file=d:\daochu.dmp full=y\x0d\x0a\x0d\x0a2、如果導入時,數(shù)據(jù)表已經(jīng)存在,將報錯,對該表不會進行導入;加上ignore=y即可,表示忽略現(xiàn)有表,在現(xiàn)有表上追加記錄。\x0d\x0aimp scott/accp@orcl file=d:\daochu.dmp full=y ignore=y\x0d\x0a\x0d\x0a3、將d:\daochu.dmp中的表emp導入\x0d\x0aimp scott/accp@orcl file=d:\daochu.dmp tables=(emp)
新聞標題:oracle如何拷數(shù)據(jù) oracle拷貝文件數(shù)據(jù)遷移
轉(zhuǎn)載來于:http://chinadenli.net/article20/hgodjo.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供標簽優(yōu)化、關鍵詞優(yōu)化、網(wǎng)站改版、全網(wǎng)營銷推廣、靜態(tài)網(wǎng)站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)