select mc || '白痴' as 别名,nl+20 as 年龄 from student;
sql中 字符串和日期必须被单引号('')包括。
sql中 数字和日期可以使用 加、减、乘、除(+、-、*、/).
sql中 字符串可以使用‘||’来连接。
sql中 使用as otherName 来定义字段的别名。
select distinct department_id from employess;
sql中 distinct 关键字 可以用来删除重复行。
select 语句的过滤
[img]http://dl.iteye.com/upload/attachment/527045/d33f6905-c9d8-39a8-9720-fec8ab4bdd73.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/527047/84ec1256-bfff-3535-8f22-81861a30e12f.jpg[/img]
各个比较运算符之间的优先级
[img]http://dl.iteye.com/upload/attachment/527049/310c2674-88f2-3804-a8e2-c4345a59a68a.jpg[/img]
select * from employess
where job_id = 'SA_REP'
job_id = 'AD_PERS'
salary > 15000;
--等效于
select * from employess
where job_id = 'SA_REP' or job_id = 'AD_PERS' and salary > 15000;
两个优先级相同的 表达式 中间的关系是 'or',
不同优先级的表达式 中间的关系是 'and'。
oracle 的函数
大小写函数
[img]http://dl.iteye.com/upload/attachment/527054/892b0206-af83-3115-975c-3fe3bb0f3fc4.jpg[/img]
字符串控制函数
[img]http://dl.iteye.com/upload/attachment/527058/150f59ba-db72-321c-89d2-2afcbe6e9f3f.jpg[/img]
其中instr 如果只有一个显示的是位置,一个以上显示的是个数。
数字函数
[img]http://dl.iteye.com/upload/attachment/527067/3a02b4f6-5c44-3a06-af07-dcaffeb7d2eb.jpg[/img]
日期函数
[img]http://dl.iteye.com/upload/attachment/527070/9c278284-8d5c-3ce9-8783-56c30a702576.jpg[/img]