Oracle學(xué)習(xí)筆記(五)
更新時(shí)間:2011年12月28日 22:56:23 作者:
最近需要用的oracle,所以大家好好的學(xué)習(xí)下基礎(chǔ)并整理下資料,希望能幫助到需要的朋友。
組合集總計(jì):
group by with rollup/cube
grouping sets
子查詢按執(zhí)行方式分:標(biāo)準(zhǔn)子查詢、關(guān)聯(lián)子查詢
標(biāo)準(zhǔn)子查詢:嵌套子查詢
標(biāo)量值查詢
case with then
使用exits查詢
select user_id,user_name from tb_001 tb
where [not] exists (select 'x'
from tb_001
where manager_id=tb.user_id )
關(guān)聯(lián)更新
update table1 alias1
set column=(select expression
from table2 alias2
where alias1.column=alias2.column);
關(guān)聯(lián)刪除
delete from table1 alias11
where column operator
(select expression
from table2 alias2
where alias1.column=alias2.column);
分層結(jié)構(gòu)
分層檢索
select [level],column,expr...
from table
[where with condition(s)]
[connect by prior condition(s)]
connect by prior column1=column2
top down:
colum1=parentkey
column2=childkey
bottom up:
column1=childkey
column2=parentkey
插入語(yǔ)句insert statement
insert into table[(column[,column...])]
values(value[,value...])
修改語(yǔ)句update statement
update table
set column=value[,column=value,...]
[where condition];
多表插入語(yǔ)句(Multitable Insert Statements)
insert [all] [conditional_insert_clause]
[insert_into_cause values_clause](subquery)
conditional_insert_clause
[all][first]
[when condition then][insert_into_clause values_clause]
[else][insert_into+clause values_clause]
列:
intsert all
into tb_user values(id,uid,upwd)
into tb_user_info values(id,name,sex,age)
select id,uid,upwd,name,sex,age
from tb_u_10
where id>10000;
待條件的多行插入
insert all
when id>11000 then
into tb_user values(id,uid,upwd)
when age>40 then
into tb_user_info values(id,name,sex,age)
select id,uid,upwd,name,sex,age
from tb_u_10
where id>10000;
insert first
when conditional then
into ...
when conditional then
into ...
else
into...
select...
創(chuàng)建索引
cretate table t_10
(id number(6) not null primary key using index (create index index1 on t_10(id)),
name varchar2(50));
查詢索引
select * from user_indexes;
group by with rollup/cube
grouping sets
子查詢按執(zhí)行方式分:標(biāo)準(zhǔn)子查詢、關(guān)聯(lián)子查詢
標(biāo)準(zhǔn)子查詢:嵌套子查詢
標(biāo)量值查詢
case with then
使用exits查詢
select user_id,user_name from tb_001 tb
where [not] exists (select 'x'
from tb_001
where manager_id=tb.user_id )
關(guān)聯(lián)更新
update table1 alias1
set column=(select expression
from table2 alias2
where alias1.column=alias2.column);
關(guān)聯(lián)刪除
delete from table1 alias11
where column operator
(select expression
from table2 alias2
where alias1.column=alias2.column);
分層結(jié)構(gòu)
分層檢索
select [level],column,expr...
from table
[where with condition(s)]
[connect by prior condition(s)]
connect by prior column1=column2
top down:
colum1=parentkey
column2=childkey
bottom up:
column1=childkey
column2=parentkey
插入語(yǔ)句insert statement
insert into table[(column[,column...])]
values(value[,value...])
修改語(yǔ)句update statement
update table
set column=value[,column=value,...]
[where condition];
多表插入語(yǔ)句(Multitable Insert Statements)
insert [all] [conditional_insert_clause]
[insert_into_cause values_clause](subquery)
conditional_insert_clause
[all][first]
[when condition then][insert_into_clause values_clause]
[else][insert_into+clause values_clause]
列:
intsert all
into tb_user values(id,uid,upwd)
into tb_user_info values(id,name,sex,age)
select id,uid,upwd,name,sex,age
from tb_u_10
where id>10000;
待條件的多行插入
insert all
when id>11000 then
into tb_user values(id,uid,upwd)
when age>40 then
into tb_user_info values(id,name,sex,age)
select id,uid,upwd,name,sex,age
from tb_u_10
where id>10000;
insert first
when conditional then
into ...
when conditional then
into ...
else
into...
select...
創(chuàng)建索引
cretate table t_10
(id number(6) not null primary key using index (create index index1 on t_10(id)),
name varchar2(50));
查詢索引
select * from user_indexes;
相關(guān)文章
Oracle9i的全文檢索技術(shù)開發(fā)者網(wǎng)絡(luò)Oracle
Oracle9i的全文檢索技術(shù)開發(fā)者網(wǎng)絡(luò)Oracle...2007-03-03Oracle使用游標(biāo)進(jìn)行分批次更新數(shù)據(jù)的6種方式及速度比對(duì)
這篇文章主要介紹了Oracle使用游標(biāo)進(jìn)行分批次更新的5種方式及速度比對(duì),幫助大家更好的理解和使用數(shù)據(jù)庫(kù),感興趣的朋友可以了解下2020-10-10Oracle 11g實(shí)現(xiàn)安全加固的完整步驟
這篇文章主要給大家介紹了關(guān)于Oracle 11g實(shí)現(xiàn)安全加固的完整步驟,文中通過示例代碼將實(shí)現(xiàn)的步驟一步步介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Oracle 11g具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2018-05-05Oracle還原恢復(fù)啟動(dòng)時(shí)數(shù)據(jù)庫(kù)報(bào)ORA-00704、 ORA-00604,、ORA-00904的問題解決
這篇文章主要介紹了Oracle還原恢復(fù)啟動(dòng)時(shí)數(shù)據(jù)庫(kù)報(bào)ORA-00704、 ORA-00604,、ORA-00904的問題解決,本文給大家講解的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-04-04詳解Oracle數(shù)據(jù)庫(kù)中自帶的所有表結(jié)構(gòu)(sql代碼)
這篇文章主要介紹了Oracle數(shù)據(jù)庫(kù)中自帶的所有表結(jié)構(gòu),本文給大家介紹的非常詳細(xì),代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-11-11Oracle執(zhí)行Update語(yǔ)句的幾種方式
這篇文章介紹了Oracle執(zhí)行Update語(yǔ)句的幾種方式,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-05-05