oracle基础

设计表的时候应该注意的三范式:

   第一范式:不能有重复数据  主键解决     第二范式:部分依赖 多对多 拆表  中间表    第三范式:消除传递依赖  一对多  拆表   主外键关联 

下面让我们来理解下select查询语句, 一个select语句 基本由以下部分组成: select * from tableName where 条件1 and 条件2 group by  having order  by    有这么一个小细节就

是and 的两个条件会先执行后面的条件2 所以写select语句的时候,要把条件2写后面

        那么他的执行顺序是怎样的呢?  先from 这个from就像java中的for循环的for 再where 可以理解成for循环中的条件  再从后往前 group by  having  再select  再 order by

where 条件  :  >    >=   <=  any   some  all   in      not in     exists      not   exists    用exists要比in的效率高  exists走索引    like        between and 

增删改:

insert  into values()     insert into  tabName(列1,。。。) values(值1,。。。)   insert into select 语句;——>拷贝数据

delete from where-->相当于拉出来一个个枪毙     truncate table  表名;-->直接扔个手榴弹  

delete from 表名 as a   where  a.rowid!=(select max(rowid) from 表明 as b where b.字段=a.字段)-->经典删除重复数据的语句

update  表名  as a  set 。。。,。。。 where 条件;

事务:commit;rollback;save point;rollback to 保存点; 特征:原子性  一致性  隔离性  持久性  

建表: creat table  creat table as select * where 1=1;

约束: 主键 唯一非空 自定义 外键

视图:

索引:

序列:

oracle 分页:select * from (select  a.*,rownum r from (select e.* from emp e order by e.sal desc )  a   where rownum<=10) b where b.r>=6;

你可能感兴趣的:(oracle基础)