Oracle数据操作增删改查

笔记时间:2016年11月1日


  1. Oracle内事问百度外事问谷歌

查询
  1. 基础查询:
  2. select column1(字段名1),column2(字段名2)|*(*代表所有) from table_name(表名) where conditions(条件);
  3. 字段去重:
  4. select distinct column(字段名) from table_name;
  5. 运算符与表达式:
  6. 算数运算符:(+ - * /)
  7. 比较运算符:(> >= < <= = <>)最后是不等于
  8. 逻辑运算符:(and or not)与或非
  9. 模糊查询:
  10. select * from table_name(表名) where column(字段名) like '%条件%';
  11. 一个_只能代表一个字符
  12. %可以代表0到多个任意字符
  13. 范围查询:
  14. select * from table_name(表名) where column(字段) between 小值 and 大值;
  15. select * from table_name(表名) where column in(条件1,条件2)
  16. 升降序:
  17. select * from table_name(表名) where 条件 order by column(字段) desc(降序)|asc(升序);
  18. case...when语句:
  19. 第一种形式:
  20. select column1(字段1),case column2(字段2) when '条件1' then 'value1' when '条件2' then 'value2' else '当前两个条件都未达成后的value' end(end结束) from table_name(表名);
  21. 第二种形式:
  22. select column1(字段1),case when '条件1' then 'value1' when '条件2' then 'value2' else '当前两个条件都未达成后的value' end(end结束) from table_name(表名);
  23. decode语句:
  24. select column1(字段1),decode (column2(字段2),'条件1',value1,'条件2',value2,else) as 别名 from table_name(表名);