使用PL/SQL,很方便導(dǎo)出。
員工經(jīng)過長(zhǎng)期磨合與沉淀,具備了協(xié)作精神,得以通過團(tuán)隊(duì)的力量開發(fā)出優(yōu)質(zhì)的產(chǎn)品。創(chuàng)新互聯(lián)建站堅(jiān)持“專注、創(chuàng)新、易用”的產(chǎn)品理念,因?yàn)椤皩W⑺詫I(yè)、創(chuàng)新互聯(lián)網(wǎng)站所以易用所以簡(jiǎn)單”。公司專注于為企業(yè)提供成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開發(fā)、電商網(wǎng)站開發(fā),重慶小程序開發(fā),軟件按需網(wǎng)站策劃等一站式互聯(lián)網(wǎng)企業(yè)服務(wù)。
選擇菜單項(xiàng)的“Tools”-“Export
Tables”;
會(huì)顯示當(dāng)前賬號(hào)的所有表格,選擇一個(gè)需要導(dǎo)出的表名(也可以選多個(gè));
在Output
File設(shè)置導(dǎo)出文件的路徑和格式;
點(diǎn)擊“Export”按鈕,導(dǎo)出表格,同時(shí)會(huì)跳出來Dos提示窗口,待執(zhí)行完畢就成功。
oracle 導(dǎo)出部分?jǐn)?shù)據(jù)
exp neto2/iam2.11@fcjwwdb file=d:\test.dmp tables=comp_銷售人員 query="""where name='劉紅英'"""
exp neto2/iam2.11@fcjwwdb file=d:\test.dmp tables=comp_銷售人員 query=\" where name='劉紅英'\"
imp neto2/iam2.11@fcjwwdb file=d:\test.dmp tables=comp_銷售人員 ignore=y
不創(chuàng)建表(ignore=y)
Oracle exp query參數(shù) 轉(zhuǎn)義符的各個(gè)操作系統(tǒng)通用解決方法
現(xiàn)在各個(gè)平臺(tái)上通用的解決方法是采用parfile來解決:
windows平臺(tái)的方法如下:
首先建立一個(gè)1.txt文件:
tables=employee
file=f:\exp.dmp
query="where name='劉紅英'"
然后:exp neto2/iam2.11@fcjwwdb parfile=1.txt
其他操作系統(tǒng)平臺(tái)的都類似。
1 將數(shù)據(jù)庫TEST完全導(dǎo)出,用戶名system 密碼manager 導(dǎo)出到D:\daochu.dmp中
exp system/manager@TEST file=d:\daochu.dmp full=y
2 將數(shù)據(jù)庫中system用戶與sys用戶的表導(dǎo)出
exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)
3 將數(shù)據(jù)庫中的表inner_notify、notify_staff_relat導(dǎo)出
exp aichannel/aichannel@TESTDB2 file= d:\data\newsmgnt.dmp tables=inner_notify,notify_staff_relat)
4 將數(shù)據(jù)庫中的表table1中的字段filed1以"00"打頭的數(shù)據(jù)導(dǎo)出
exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=\" where filed1 like '00%'\"
來源:
可用sqlplus的方式
先在某文件夾下(我就直接以C盤根目錄為例了)
創(chuàng)建main.sql文件
內(nèi)容如下
set linesize 200
set term off verify off feedback off pagesize 0
set head off
set trimout on
set trimspool on
spool aaa.txt
@export.sql
spool off
exit
其中aaa.txt是你要保存的文件名,這里貌似不能導(dǎo)成excel,只可以保存成csv格式,然后你再自己轉(zhuǎn)換吧,文本是沒問題的,其中@export.sql 是另一個(gè)文件,內(nèi)容如下
你要想把數(shù)據(jù)導(dǎo)成以逗號(hào)分隔
腳本這么寫
我就簡(jiǎn)單以emp表為例了,也是用的to_char函數(shù),只要語句寫正確就OK
select empno||','||to_char(hiredate,'yyyy-mm-dd') from emp;
結(jié)尾必須用分號(hào)
把這個(gè)保存成export.sql文件
然后cmd進(jìn)到你要執(zhí)行的文件夾下
sqlplus 用戶名/密碼 @main
然后無限的等待,等到把你的文件導(dǎo)成
你將來要是要把文件導(dǎo)入到哪的話,可以用sqlloader
這個(gè)網(wǎng)上教程很多
哎,打字這個(gè)累呀
Oracle導(dǎo)出導(dǎo)出有兩中方式:一、利用exp imp導(dǎo)出導(dǎo)入;二、利用Oracel數(shù)據(jù)泵expdp impdp導(dǎo)出導(dǎo)入。
一、利用exp imp導(dǎo)出導(dǎo)入
exp imp 語法如下:
exp:
1) 將數(shù)據(jù)庫orcl完全導(dǎo)出
exp system/manager@orcl file=d:\orcl_bak.dmp full=y
2) 將數(shù)據(jù)庫中system用戶的表導(dǎo)出
exp system/manager@orcl file=d:\system_bak.dmp owner=system
3) 將數(shù)據(jù)庫中表table1,table2導(dǎo)出
exp system/manager@orcl file=d:\table_bak.dmp tables=(table1,table2)
4) 將數(shù)據(jù)庫中的表customer中的字段mobile以"139"開頭的數(shù)據(jù)導(dǎo)出
exp system/manager@orcl file=d:\mobile_bak.dmp tables=customer query=\"where mobile like '139%' \"
imp:
1) 將備份文件bak.dmp導(dǎo)出數(shù)據(jù)庫
imp system/manager@orcl file=d:\bak.dmp
如果數(shù)據(jù)表中表已經(jīng)存在,會(huì)提示錯(cuò)誤,在后面加上ignore=y就可以了。
2) 將備份文件bak.dmp中的表table1導(dǎo)入
imp system/manager@orcl file=d:\bak.dmp tables=(table1)
exp imp導(dǎo)出導(dǎo)入數(shù)據(jù)方式的好處是只要你本地安裝了Oracle客戶端,你就可以將服務(wù)器中的數(shù)據(jù)導(dǎo)出到你本地計(jì)算機(jī)。同樣也可以將dmp文件從你本地導(dǎo)入到服務(wù)器數(shù)據(jù)庫中。但是這種方式在Oracle11g版本中會(huì)出現(xiàn)一個(gè)問題:不能導(dǎo)出空表。Oracle11g新增了一個(gè)參數(shù)deferred_segment_creation,含義是段延遲創(chuàng)建,默認(rèn)是true。當(dāng)你新建了一張表,并且沒用向其中插入數(shù)據(jù)時(shí),這個(gè)表不會(huì)立即分配segment。
解決辦法:
1、設(shè)置deferred_segment_creation參數(shù)為false后,無論是空表,還是非空表,都分配segment。
在sqlplus中,執(zhí)行如下命令:
SQLalter system set deferred_segment_creation=false;
查看:
SQLshow parameter deferred_segment_creation;
該值設(shè)置后,只對(duì)后面新增的表起作用,對(duì)之前建立的空表不起作用,并且注意要重啟數(shù)據(jù)庫讓參數(shù)生效。
2、使用 ALLOCATE EXTEN
使用 ALLOCATE EXTEN可以為數(shù)據(jù)庫對(duì)象分配Extent,語法如下:
alter table table_name allocate extent
構(gòu)建對(duì)空表分配空間的SQL命令:
SQLselect 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
批量生成要修改的語句。
然后執(zhí)行這些修改語句,對(duì)所有空表分配空間。
此時(shí)用exp命令,可將包括空表在內(nèi)的所有表導(dǎo)出。
二、利用expdp impdp導(dǎo)出導(dǎo)入
在Oracle10g中exp imp被重新設(shè)計(jì)為Oracle Data Pump(保留了原有的 exp imp工具)
數(shù)據(jù)泵與傳統(tǒng)導(dǎo)出導(dǎo)入的區(qū)別;
1) exp和imp是客戶端工具,他們既可以在客戶端使用,也可以在服務(wù)端使用。
2) expdp和impdp是服務(wù)端工具,只能在Oracle服務(wù)端使用。
3) imp只適用于exp導(dǎo)出文件,impdp只適用于expdp導(dǎo)出文件。
expdp導(dǎo)出數(shù)據(jù):
1、為輸出路徑建立一個(gè)數(shù)據(jù)庫的directory對(duì)象。
create or replace directory dumpdir as 'd:\';
可以通過:select * from dba_directories;查看。
2、給將要進(jìn)行數(shù)據(jù)導(dǎo)出的用戶授權(quán)訪問。
grant read,write on directory dumpdir to test_expdp;
3、將數(shù)據(jù)導(dǎo)出
expdp test_expdp/test_expdp directory=dumpdir dumpfile=test_expdp_bak.dmp logfile=test_expdp_bak.log schemas=test_expdp
注意:這句話在cmd窗口中運(yùn)行,并且最后不要加分號(hào),否則會(huì)提示錯(cuò)誤。因?yàn)檫@句話是操作系統(tǒng)命令而不是SQL。
impdp導(dǎo)入數(shù)據(jù):
1、給將要進(jìn)行數(shù)據(jù)導(dǎo)入的用戶授權(quán)訪問。
grant read,write on directory dumpdir to test_impdp;
2、將數(shù)據(jù)導(dǎo)入
impdp test_impdp/impdp directory=dumpdir dumpfile=test_expdp_bak.dmp remap_schema=test_expdp:test_impdp
BMP ? dmp吧,這個(gè)是Oracle的導(dǎo)出文件。 據(jù)我所知,應(yīng)該沒有辦法直接從dmp文件中提取數(shù)據(jù)。 應(yīng)該將dmp文件導(dǎo)入(恢復(fù))到Oracle數(shù)據(jù)庫中, 然后再使用普通的sql語句進(jìn)行檢索, 通過pl/sql dev、navicat 客戶端 等等工具就可以導(dǎo)出成excel了
1
將數(shù)據(jù)庫TEST完全導(dǎo)出,用戶名system
密碼manager
導(dǎo)出到D:\daochu.dmp中
exp
system/manager@TEST
file=d:\daochu.dmp
full=y
2
將數(shù)據(jù)庫中system用戶與sys用戶的表導(dǎo)出
exp
system/manager@TEST
file=d:\daochu.dmp
owner=(system,sys)
3
將數(shù)據(jù)庫中的表table1
、table2導(dǎo)出
exp
system/manager@TEST
file=d:\daochu.dmp
tables=(table1,table2)
4
將數(shù)據(jù)庫中的表table1中的字段filed1以"00"打頭的數(shù)據(jù)導(dǎo)出
exp
system/manager@TEST
file=d:\daochu.dmp
tables=(table1)
query=\"
where
filed1
like
'00%'\"
上面是常用的導(dǎo)出,對(duì)于壓縮我不太在意,用winzip把dmp文件可以很好的壓縮。
不過在上面命令后面
加上
compress=y
就可以了
網(wǎng)站題目:怎么導(dǎo)出oracle字段,oracle導(dǎo)出數(shù)據(jù)語句
分享網(wǎng)址:http://aaarwkj.com/article34/dsishpe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)站營(yíng)銷、微信公眾號(hào)、外貿(mào)建站、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)