1ãæå¼è¦å¯¼åºä¸ºoracleçExcel,å°Excelæ件ä¿å为test.txtæ件ï¼æ件->å¦å为ï¼
2ãå建SQL*Loaderè¾å
¥æ°æ®æéè¦çæ件ï¼åä¿åå°C:ï¼ç¨è®°äºæ¬ç¼è¾ï¼
æ§å¶æ件ï¼input.ctlï¼å
容å¦ä¸ï¼
ãload dataããããããããã--1ãæ§å¶æ件æ è¯
ãinfile 'test.txt'ãããããã --2ãè¦è¾å
¥çæ°æ®æ件å为.txt,注æè·¯å¾
ãappend intotable Table_Nameã --3ãåoracle表ä¸è¿½å è®°å½
ãfields terminatedby X'09'ãã --4ãå段ç»æ¢äºX'09'ï¼æ¯ä¸ä¸ªå¶è¡¨ç¬¦ï¼TABï¼
ã(Col1,Col2â¦)ãã å®ä¹å对åºé¡ºåº
ããaãinsertï¼ä¸ºç¼ºçæ¹å¼ï¼å¨æ°æ®è£
è½½å¼å§æ¶è¦æ±è¡¨ä¸ºç©º
ããbãappendï¼å¨è¡¨ä¸è¿½å æ°è®°å½
ããcãreplaceï¼å é¤æ§è®°å½ï¼æ¿æ¢ææ°è£
è½½çè®°å½
ããdãtruncateï¼åä¸
3ãå¨DOSçªå£ä¸ä½¿ç¨SQL*Loaderå½ä»¤å®ç°æ°æ®çè¾å
¥
C:>sqlldr userid=system/managercontrol=input.ctl
é»è®¤æ¥å¿æ件å为ï¼input.log
é»è®¤åè®°å½æ件为ï¼input.bad
4ãok,ç°å¨å°±å¯ä»¥æ¥çæ°æ®æ¯å¦å¯¼å
¥äºã
ORACLESQL Loaderç详ç»è¯æ³
SQL*LOADERæ¯ORACLEçæ°æ®å 载工å
·ï¼é常ç¨æ¥å°æä½ç³»ç»æ件è¿ç§»å°ORACLEæ°æ®åºä¸ãSQL*LOADERæ¯å¤§åæ°æ®ä»åºéæ©ä½¿ç¨çå è½½æ¹æ³ï¼å 为å®æä¾äºæå¿«éçéå¾ï¼DIRECTï¼PARALLELï¼ã
è¦ä½¿ç¨SQL*Loaderï¼å¿
é¡»ç¼è¾ä¸ä¸ªæ§å¶æ件(.ctl),åä¸ä¸ªæ°æ®æ件(.dat)
é¦å
ï¼æ们认è¯ä¸ä¸SQL*LOADER
å¨windowsä¸ï¼SQL*LOADERçå½ä»¤ä¸ºSQLLDRï¼å¨UNIXä¸ä¸è¬ä¸ºsqlldr/sqlloadã
å¦æ§è¡ï¼d:\oracle>sqlldr
ç¨æ³: SQLLOAD å
³é®å=å¼ [,keyword=value,...]
ä¾å¦ï¼>sqlldr user/pass
control=æ§å¶æ件å log=æ¥å¿æ件å
SQL*LOADERåæ°å表
åæ°å称
åè½æè¿°
Userid
æ°æ®åºç¨æ·ååå£ä»¤
Control
æ§å¶æ件å称ï¼æè¿°æ°æ®å è½½çæ件信æ¯
Log
æ¥å¿æ件å称ï¼ç¨äºè®°å½æ°æ®å è½½è¿ç¨çä¿¡æ¯
Bad
åä¿¡æ¯æ件å称ï¼ç¨äºè®°å½ä¸ç¬¦åè¦æ±çæ°æ®ä¿¡æ¯
Data
æ°æ®æ件å称ï¼è®°å½è¦å è½½çåå§æ°æ®
Discard
丢ææ件å称ï¼è®°è½½äºä¸æ»¡è¶³æ¡ä»¶è被è¿æ»¤çæ°æ®
Discardmax
å
许丢ææ°æ®éï¼é»è®¤ä¸ºå
¨é¨ä¸¢æ
Skip
è·³è¿å 个é»è¾è®°å½ï¼ç¼ºç为0
Load
è¦å è½½çè®°å½æ°ï¼é»è®¤ä¸ºå
¨é¨å è½½
Errors
å
许åºç°çé误æ°ï¼ç¼ºç为50
Direct
æ¯å¦ä½¿ç¨ç´æ¥è·¯å¾å è½½æ°æ®ï¼é»è®¤ä¸ºfalse
Readsize
ç¼å²åºå¤§å°é»è®¤ä¸º1048576åè
1ãé¦å
å建空表
SQL>create table stu(stunonumber(5),name varchar(10),addr
varchar(20));
æ°æ®æä»¶æ ¼å¼å为èªç±æ ¼å¼ååºå®æ ¼å¼
åºå®æ ¼å¼æ°æ®æ件(mydata.txt)
001 SHUI LIAOHE
002 LIU BEIJING
å
¶æ§å¶æ件åå«å¦ä¸
#Load.ctl
Load data
Infile mydata.txt
Into table stu
(stuno position(01:03) integer external,
Name position(05:08) varchar,
Addr position(10:16) varchar)
导å
¥æ°æ®
>sqlldr test1/test1 control=âd:\load.ctlâlog=âd:\load.logâ
èªç±æ ¼å¼æ°æ®æ件(mydata.txt)
003,âshuicsâ,ânew yorkâ
004,âliujianxinâ,âBeijingâ
005,âshuiymâ,âCanadaâ
å
¶æ§å¶æ件å¦ä¸
#load.ctl
Load data
Infile mydata.txt
Append|insert|replace|truncate
Into table stu
Fields terminated by â,â
Optionally enclosed by âââ
(stuno,name,addr)
导å
¥æ°æ®
å°Excelæ°æ®å è½½å°oracleæ°æ®åº
1ãå°excelæ件å¦å为ææ¬æ件ï¼å¶è¡¨ç¬¦åéï¼
2ãå建æ§å¶æ件å¦ä¸
Load data
Infile âbook.txtâ
Append
Into table stu
Fields terminated by Xâ09â
(stuno,name,addr)
å
¶ä¸Xâ09âæ¯ä¸ä¸ªå¶è¡¨ç¬¦(TAB)
温馨提示:答案为网友推荐,仅供参考