1过滤
where语句是将不满足条件的进行过滤掉
1.select 条件, 条件,…
from 列表
[where 条件]
select ename , sal,
from tab
where sal>200
在ename和sal连个选项中输出sal值大于200的值
注意字符和日期:
字符和日期要用单引号
字符大小敏感,日期格式敏感
日期的默认格式为 dd-mon-rr
例如
select name , date
from tab
where name=‘tom’;
就是经名字是Tom的输出出来
2.比较运算符有:< ,> ,= ,<=,>=, <>,between…and…
in , like , is null
以上的运算符重点介绍between…and… in like is null
例如:
select number
from tab
where between 10 and 20;
在tab的列表中选择数字在10 和20 之间的数字
select number
from tab
where in (10 ,20 ,30);
在tab列表中选择10 20 或30 这几个数字
select name
from tab
where name=like‘t%’
在tab列表中筛选出名字中带t的
这里注意%表示一个或多个字符,
_表示一个字符000
select number
from tab
where number is null;
将数字是空值得输出来
3.逻辑运算符
and 逻辑并,表示两个条件都为真
or 逻辑或,有一个为真即可
not 逻辑否 如果条件为假则输出为真
select A,B,C,D
from tab
where a>20
and a =boy ;
表示大于20岁的男生挑选出来
or 和not 同理
4.数据库中表达式拥有优先级
降序排列
select a , b ,c
friom tab
order by desc
alter session set nls_date_format = ‘YYYY-MM-DD hh24;mi:ss’;
修改日期的格式
select sysdate from dual;
查看当前数据库的操作时间
set pages 200 lines 200
修改显示行列