版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、oracle9i 對 dml 和 ddl 語句的擴(kuò)展,目標(biāo),通過本章學(xué)習(xí),您將可以: 描述多表插入的特點(diǎn) 使用不同類型的多表插入 無條件的insert 旋轉(zhuǎn) insert 有條件的 all insert 有條件的 first insert 創(chuàng)建和使用外部表 創(chuàng)建主鍵約束的同時創(chuàng)建索引,insert 語句,使用 insert 語句向表中插入新的數(shù)據(jù) 使用上面的語句每次只能向表中插入一行數(shù)據(jù),insert intotable (column , column.) values(value , value.,insert into departments(department_id, departm
2、ent_name, manager_id, location_id) values (70, public relations, 100, 1700); 1 row created,update 語句,使用update 語句更新表中的數(shù)據(jù) 使用上面的語句每次可更新表中的一行或多行數(shù)據(jù) 使用 where 子句指定更新的條件,updatetable setcolumn = value , column = value, . where condition,update employees set department_id = 70 where employee_id = 142; 1 row u
3、pdated,多表 insert 語句,insert.select 是使用一個dml 語句向多個表中插入數(shù)據(jù)的一部分 多表insert 語句可作為數(shù)據(jù)倉庫應(yīng)用中向目標(biāo)數(shù)據(jù)庫傳送數(shù)據(jù)的一種方法 它具有更高的效率: 避免使用多各dml 語句 使用一個dml 完成 if.then 的邏輯處理,多表 insert 語句的類型,oracle9i 提供以下四種多表insert 語句類型: 無條件的 insert 有條件的 all insert 有條件的 first insert 旋轉(zhuǎn) insert,多表 insert 語句,insert all conditional_insert_clause inse
4、rt_into_clause values_clause (subquery,all first when condition then insert_into_clause values_clause else insert_into_clause values_clause,conditional_insert_clause,語法,無條件的 insert all 應(yīng)用舉例,insert all into sal_history values(empid,hiredate,sal) into mgr_history values(empid,mgr,sal) select employee_
5、id empid, hire_date hiredate, salary sal, manager_id mgr from employees where employee_id 200; 8 rows created,有條件的 insert all 應(yīng)用舉例,insert all when sal 10000 then into sal_history values(empid,hiredate,sal) when mgr 200 then into mgr_history values(empid,mgr,sal) select employee_id empid,hire_date hi
6、redate, salary sal, manager_id mgr from employees where employee_id 200; 4 rows created,有條件的 first insert 應(yīng)用舉例,insert first when sal 25000 then into special_sal values(deptid, sal) when hiredate like (%00%) then into hiredate_history_00 values(deptid,hiredate) when hiredate like (%99%) then into hir
7、edate_history_99 values(deptid, hiredate) else into hiredate_history values(deptid, hiredate) select department_id deptid, sum(salary) sal, max(hire_date) hiredate from employees group by department_id; 8 rows created,旋轉(zhuǎn) insert 應(yīng)用舉例,insert all into sales_info values (employee_id,week_id,sales_mon) i
8、nto sales_info values (employee_id,week_id,sales_tue) into sales_info values (employee_id,week_id,sales_wed) into sales_info values (employee_id,week_id,sales_thur) into sales_info values (employee_id,week_id, sales_fri) select employee_id, week_id, sales_mon, sales_tue, sales_wed, sales_thur,sales_
9、fri from sales_source_data; 5 rows created,外部表,外部表是只讀的表,其數(shù)據(jù)存儲在數(shù)據(jù)庫外的平面文件中 外部表的各種參數(shù)在 create table 語句中指定 使用外部表, 數(shù)據(jù)可以存儲到外部文件或從外部文件中上載數(shù)據(jù)到數(shù)據(jù)庫 數(shù)據(jù)可以使用 sql訪問, 但不能使用 dml 后在外部表上創(chuàng)建索引,創(chuàng)建路徑,創(chuàng)建外部表之前應(yīng)先使用create directory語句創(chuàng)建路徑,create directory emp_dir as /flat_files,創(chuàng)建外部表舉例,create table oldemp ( empno number, empnam
10、e char(20), birthdate date) organization external (type oracle_loader default directory emp_dir access parameters (records delimited by newline badfile bad_emp logfile log_emp fields terminated by , (empno char, empname char, birthdate char date_format date mask dd-mon-yyyy) location (emp1.txt) parallel 5 reject limit 200; table created,查詢外部表,select * from oldemp,emp1.txt,創(chuàng)建主鍵約束同時創(chuàng)建索引舉例,create table new_emp (employee_id number(6) primary key using index (create index emp_id_idx on new_emp(employee_id), first_name varchar2(20),last_name varchar2(25); table created,select ind
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 信息技術(shù)融合課教學(xué)設(shè)計(jì)表
- 《汽車信息安全通 用技術(shù)要求gbt+40861-2021》詳細(xì)解讀
- 電子商務(wù)進(jìn)農(nóng)村綜合示范項(xiàng)目申報(bào)表
- 人美版2018-2019學(xué)年四年級美術(shù)上冊全冊教案
- 浙美版小學(xué)美術(shù)五年級下冊教案+教學(xué)計(jì)劃
- 廣東省深圳市五年級上學(xué)期英語期中試卷九(含答案)
- 新教材同步備課2024春高中化學(xué)第7章有機(jī)化合物實(shí)驗(yàn)活動8搭建球棍模型認(rèn)識有機(jī)化合物分子結(jié)構(gòu)的特點(diǎn)課件新人教版必修第二冊
- 新教材同步系列2024春高中地理第三章環(huán)境與國家安全第四節(jié)環(huán)境保護(hù)與國家安全課件中圖版選擇性必修3
- 學(xué)生成績提升的心得體會
- 外研版小學(xué)英語四年級下冊教案全套
- DB3305-T 247-2022《銀行信貸碳排放核算通則》
- 棚戶區(qū)改造入戶調(diào)查表
- 實(shí)驗(yàn)診斷學(xué) 臨床常用生物化學(xué)檢測課件
- 3PE防腐涂層剝離作業(yè)方案
- 魯教版九年級化學(xué)方程式
- 管材采購1投標(biāo)文件
- 控?zé)煿ぷ鳈z查及記錄表
- 腦干出血課件
- 弱電系統(tǒng)運(yùn)維服務(wù)方案
- 二年級下冊音樂教案 (簡譜) 9.1 《螃蟹歌》 湘藝版
- 第四至第十一屆泛珠力學(xué)基礎(chǔ)試試題及答案
評論
0/150
提交評論