多表链接
92语法
笛卡尔积(select * from A,B;)
等值连接
select ....from A,B where A.a=B.b
非等值连接
select ... from A,B where A.a between a1 and a2
外连接
主表:所有的数据都能显示,在连接条件上在主表对面的表上添加(+)
主表在逗号的左边就是左外连接
主表在逗号的左边就是右外连接
自连接
select A1.a1 ,A2.a1 from A A1 , A A2 where A1.a1=A2.a2
99语法
等值连接
自然连接
natural join(同名列不能写限定词)
select * from A natural B
table1 join on table2
可以做等值也可以做非等值判断
外连接
左外连接 观察主表在from emp dept在逗号的左边就是左外连接 left join
右外连接 观察主表在from emp dept在逗号的左边就是右外连接 right join
自连接
select A1.a1 ,A2.a1 from A A1 join A A2 on A1.a1=A2.a2
全连接
full join
select * from A full join B on ...
rowid伪列,每一行记录的标识,在行记录插入表时就确定的,相当于对象的地址
rownum 伪列 结果集的序号,从1开始
如果按照主键进行排序先排序后确定rownum
如果按照非主键字段排序,先确定rownum再排序
视图
创建 create or replace view view_name select ...
删除
drop view view_name
索引
创建
create index index_name on table_name(字段名)
删除
drop index index_name
表
创建
create table table_name(......)
删除
drop table table_name(...)
插入值
insert into table_name(...) values(...)
删除数据
delect from table_name where ...
加入注释
comment
约束
primary key
not null
check()
unique
追加
alter table table_name add constranit 约束名 约束条件(字段)
删除
alter table table_name drop constranit 约束名
oracle 多表查询
最新推荐文章于 2023-07-16 22:52:50 发布
