算术操作符
算术操作符包括加(+)、减(-)、乘(*)、除(/)
对所有学生年龄加1
比较操作符包括 =、!=、<、>、<=、>=、BETWEEN…AND、IN、LIKE 和 IS NULL等
查询年龄小于19的学生
between and 表示在两个数值之间的范围
//查询分数在80和90之间的
select * from sc where grade between 80 and 90;
//也可以这样写
select * from sc where grade>=80 and grade<=90;
in的用法
//查询成绩是85或者90的
select * from sc where grade in (85, 90);
//也可以这样写
select * from sc where grade=85 or grade=90;
%表示0到多个字符
_表示1到多个字符
查询名字格式为 "_晨%"的学生
集合操作符
//并集 将查询的返回组合成一个结果 union无重复记录,union all有重复记录
select * from student where sdept=‘IS’
union
select * from student where sage<=19;
//交集 返回查询结果中相同的部分。
select * from student where sdept=‘IS’
intersect
select * from student where sage<=19;
//差集 返回在第一个查询结果中与第二个查询结果不相同的那部分行记录。
select * from student where sage<=19
minus
select * from student where sdept=‘IS’;
||将多个字符串或数据值合并成一个字符串
字符函数
ltrim、rtrim(str1,str2):除去str1中左(右)侧所含str2中的字符,如果没有参数str2,则为除去左(右)侧所含的空格;
chr和ascii
lpad和rpad 左填充,右填充
Lpad、Rpad(str1,count,str2):在str1左(右)侧填充str2,使结果串长度为count
数字函数
round 四舍五入
sysdate查看系统时间
to_char 将日期转换为字符串
HH24 24小时制
fmMM 取消填充月份前面的0
to_number将字符串转换为number类型