Oracle数据操作增删改查
笔记时间:2016年11月1日
Oracle内事问百度外事问谷歌
查询
基础查询: select column1(字段名1),column2(字段名2)|*(*代表所有) from table_name(表名) where conditions(条件);字段去重: select distinct column(字段名) from table_name;运算符与表达式: 算数运算符:(+ - * /) 比较运算符:(> >= < <= = <>)最后是不等于 逻辑运算符:(and or not)与或非模糊查询: select * from table_name(表名) where column(字段名) like '%条件%'; 一个_只能代表一个字符 %可以代表0到多个任意字符范围查询: select * from table_name(表名) where column(字段) between 小值 and 大值; select * from table_name(表名) where column in(条件1,条件2)升降序: select * from table_name(表名) where 条件 order by column(字段) desc(降序)|asc(升序);case...when语句: 第一种形式: select column1(字段1),case column2(字段2) when '条件1' then 'value1' when '条件2' then 'value2' else '当前两个条件都未达成后的value' end(end结束) from table_name(表名); 第二种形式: select column1(字段1),case when '条件1' then 'value1' when '条件2' then 'value2' else '当前两个条件都未达成后的value' end(end结束) from table_name(表名);decode语句: select column1(字段1),decode (column2(字段2),'条件1',value1,'条件2',value2,else) as 别名 from table_name(表名);