select :
标准格式: select 列表名 from table;
1;别名在列表名之后加 若是用双引号,则系统默认变为大写
2:过滤重复: select distinct 列表名 from dual;
3: 查找某一相同数据: where to_char(hire_date,'yyyy-mm-dd') = '1996-05-01'
4: 查询table所有数据: desc dual;
比较运算:= 相同于java的==
> 大于
>=大于、等于
< 小于
<=小于、等于
<>不等于 相同于java的!=
运算符:加减乘除 +-*/ --日期不能做乘除
where过滤:
where salary between 4000 and 7000 --介于两者间的数据
where 列表名 = 90 or where department_id = 80 or where department_id = 70 --为表中其中之一时
where 列表名 in(90,80,70)
where模糊查询:
where 列表名 like '%a%' --模糊查询like
模糊查询 下划线"_" where department_id like '%\_%' --此处下划线为代表查找一个字符,若要查找下划线需要在最后加转义字符escape'\'
模糊查询第三位为a '__a%' 反之模糊查询倒数第三位为a ‘%a__’
where 列表名 is null
where 列表名 not is null
order by排序:
order by salary desc降序
order by salary asc升序
多层排序
order by salary asc,last_name asc
标准格式: select 列表名 from table;
1;别名在列表名之后加 若是用双引号,则系统默认变为大写
2:过滤重复: select distinct 列表名 from dual;
3: 查找某一相同数据: where to_char(hire_date,'yyyy-mm-dd') = '1996-05-01'
4: 查询table所有数据: desc dual;
比较运算:= 相同于java的==
> 大于
>=大于、等于
< 小于
<=小于、等于
<>不等于 相同于java的!=
运算符:加减乘除 +-*/ --日期不能做乘除
where过滤:
where salary between 4000 and 7000 --介于两者间的数据
where 列表名 = 90 or where department_id = 80 or where department_id = 70 --为表中其中之一时
where 列表名 in(90,80,70)
where模糊查询:
where 列表名 like '%a%' --模糊查询like
模糊查询 下划线"_" where department_id like '%\_%' --此处下划线为代表查找一个字符,若要查找下划线需要在最后加转义字符escape'\'
模糊查询第三位为a '__a%' 反之模糊查询倒数第三位为a ‘%a__’
where 列表名 is null
where 列表名 not is null
order by排序:
order by salary desc降序
order by salary asc升序
多层排序
order by salary asc,last_name asc