標籤:有兩個簡單例子,以說明 “exists”和“in”的效率問題1) select * from T1 where exists(select 1 from T2 where T1.a=T2.a) ; T1資料量小而T2資料量非常大時,T1<<T2 時,1) 的查詢效率高。2) select * from T1 where T1.a in (select T2.a from T2)
標籤: --select name,count(id) from work_test group by name having count(id)>1--select upper(name),t.*,lower(name),substr(name,1,5) from WORK_TEST t--連表更新/*update work_test set(price)=(select t.price from work_test t where t.price=80.00 and
標籤:MERGE語句是Oracle9i新增的文法,用來合并UPDATE和INSERT語句。通過MERGE語句,根據一張表或子查詢的串連條件對另外一張表進行查詢,串連條件匹配上的進行UPDATE,無法匹配的執行INSERT。這個文法僅需要一次全表掃描就完成了全部工作,執行效率要高於INSERT+UPDATE。 文法:MERGE INTO [your table-name] [rename your table here]USING ( [write your query here] )[
標籤:--insert into添加資料insert into student(sno,sname,ssex) values(‘110‘,‘王軍‘,‘男‘);--提交事物commit;--復原事物--rollback;insert into teacher1 select * from teacher;insert into teacher1(ton,tname,prof) select ton,tname,prof from teacher;--選擇性插入兩表之間insert into