您好,登錄后才能下訂單哦!
本篇文章為大家展示了oracle中怎么創(chuàng)建外部表,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
oracle db允許以只讀的形式查詢外部表。外部表可以存儲在任何oracle db可以讀取的存儲設(shè)備中,其內(nèi)容不在db中保存,db只保存external table的metadata,db可以查詢(join、sort)external table,可以創(chuàng)建view、synonym,但不可以執(zhí)行DML語句。
創(chuàng)建外部表語法create table ......orginzition external,可以把外部表假想為一個view,可以正常的做select。
analyze 和 虛擬列 表分析不使用與外部表
創(chuàng)建外部表語法
外部表文件:
example1.txt
360,Jane,Janus,ST_CLERK,121,17-MAY-2001,3000,0,50,jjanus
361,Mark,Jasper,SA_REP,145,17-MAY-2001,8000,.1,80,mjasper
362,Brenda,Starr,AD_ASST,200,17-MAY-2001,5500,0,10,bstarr
363,Alex,Alda,AC_MGR,145,17-MAY-2001,9000,.15,80,aalda
example2.txt
401,Jesse,Cromwell,HR_REP,203,17-MAY-2001,7000,0,40,jcromwel
402,Abby,Applegate,IT_PROG,103,17-MAY-2001,9000,.2,60,aapplega
403,Carol,Cousins,AD_VP,100,17-MAY-2001,27000,.3,90,ccousins
404,John,Richardson,AC_ACCOUNT,205,17-MAY-2001,5000,0,110,jrichard
創(chuàng)建外部表oracle可識別路徑:
SQL> conn / as sysdba SQL> create directory external_dir as '/u01/app/oracle/oradata/external'; Directory created. SQL> grant read,write on directory external_dir to kevin; Grant succeeded.
外部表的使用用戶kevin,創(chuàng)建外部表
SQL> CREATE TABLE ex_employees 2 (employee_id NUMBER(4), 3 first_name VARCHAR2(20), 4 last_name VARCHAR2(25), 5 job_id VARCHAR2(10), 6 manager_id NUMBER(4), 7 hire_date DATE, 8 salary NUMBER(8,2), 9 commission_pct NUMBER(2,2), 10 department_id NUMBER(4), 11 email VARCHAR2(25) 12 ) 13 ORGANIZATION EXTERNAL 14 ( 15 TYPE ORACLE_LOADER 16 DEFAULT DIRECTORY external_dir 17 ACCESS PARAMETERS 18 ( 19 records delimited by newline 20 badfile external_dir:'empxt%a_%p.bad' 21 logfile external_dir:'empxt%a_%p.log' 22 fields terminated by ',' 23 missing field values are null 24 ( employee_id, first_name, last_name, job_id, manager_id, 25 hire_date char date_format date mask "dd-mon-yyyy", 26 salary, commission_pct, department_id, email 27 ) 28 ) 29 LOCATION ('example1.txt', 'example2.txt') 30 ) 31 PARALLEL 32 REJECT LIMIT UNLIMITED; Table created.
創(chuàng)建完成后可以可以通過cats把數(shù)據(jù)導(dǎo)入至數(shù)據(jù)庫的表中,如果數(shù)據(jù)比較多,可以開啟session level parallel導(dǎo)入
alter session enable parallel; create table employee as select * from ex_employee; EMPLOYEE_ID FIRST_NAME LAST_NAME JOB_ID MANAGER_ID HIRE_DATE SALARY COMMISSION_PCT DEPARTMENT_ID EMAIL ----------- -------------------- ------------------------- ---------- ---------- --------- ---------- -------------- ------------- ------------------------- 360 Jane Janus ST_CLERK 121 17-MAY-01 3000 0 50 jjanus 361 Mark Jasper SA_REP 145 17-MAY-01 8000 .1 80 mjasper 362 Brenda Starr AD_ASST 200 17-MAY-01 5500 0 10 bstarr 363 Alex Alda AC_MGR 145 17-MAY-01 9000 .15 80 aalda 401 Jesse Cromwell HR_REP 203 17-MAY-01 7000 0 40 jcromwel 402 Abby Applegate IT_PROG 103 17-MAY-01 9000 .2 60 aapplega 403 Carol Cousins AD_VP 100 17-MAY-01 27000 .3 90 ccousins 404 John Richardson AC_ACCOUNT 205 17-MAY-01 5000 0 110 jrichard 10 rows selected.
上述內(nèi)容就是oracle中怎么創(chuàng)建外部表,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。