Oracle知识点整理

创建主键约束
alert table 表名 add constraint 主键名 primary key(列名);
eg:Oracle知识点整理
创建外键约束
alert table 表名 add constraint 外键名 foreign key(列名) refreences 主表名(列名);
eg:Oracle知识点整理添加默认值
alert table 表名 modify 列名 default ‘默认值’;
eg:Oracle知识点整理查看某一个表的所有约束
select * from user_constraints where table_name=‘表名’;
eg:Oracle知识点整理依据现有表创建新表
create table 新表名 as select * from 旧表名 where 1=1;(条件为true数据结构都创建,false只创建结构)
eg:Oracle知识点整理去重
select distinct 列名 from 表名;
eg:Oracle知识点整理按范围查找关键字between and
模糊查询 like '_'表示任意字符 '%'表示多字符的序列
不为空 is not null
排序 order by desc/asc 升序/降序
转小写lower
转大写upper
首字母转大写initcap
连接 || concat
截取substr(字符串,开始位置,长度)
替换replace
左侧填充lpad
右侧填充rpad
去空格trim
绝对值abs(数字)
向上取整ceil(数字)
向下取整floor(数字)
取余数mod(被除数,除数)
四舍五入round(数字,从第几位开始取)
保留小数位数(数字,位数)
系统当前时间sysdate
平均数avg
分组函数 group by having(这个后面跟条件)
求排序rank(),dense_rank(),row_number()
eg:Oracle知识点整理自然连接natural join
左外连接left outer join
右外连接right outer join
全外连接full outer join
自连接self join
并集(所有内容都显示,重复的显示一次)union
并集(重复的都显示)union all
交集intersect
差集minus
子查询in和exists的性能区别
Oracle知识点整理伪列rowid rownum
分页查询
select * from
select e.*,rownum rn from(
(select * from emp)e)where rn>=3 and rn<=9;
查询重复值记录的三种方法
rowid group by distinct
事务的特性
A(Atomicity)原子性
C(Consistency)一致性
I(Isolation)隔离性
D(Durability)持久性
提交commit回滚rollback
B树索引语法 create index index_name on 表名();
Oracle知识点整理反向键索引语法create index 索引名 on 表名(列名) reverse;
位图索引语法create bitmap index 索引名 on表名 (列名);
创建序列语法
create sequence 序列名
start with 10
increment by 10
maxvalue 1000
minvalue 20
nocycle
cache 10;
nextvalue返回序列的下一个值
currval返回序列的当前值