oracle学习
sqll的语句分类:
select 数据查询
DML( make) :数据操作语言, --insert、update、delete
DDL(Data Definition(定义) Language) 数据定义语言 -- create、alter、drop、truncate
DCL( controll ) 数据控制语言 --grant、revoke
事物控制语句 ----commit、rollback 、savepoint
select查询语句
从select * from dept where d_name = "bane" 开始
select _____ from 之间 可以出现的情况
这之间正常出现的是字段名称 ,需要选择的字段名,选择所有可以使用通配符号 * 代替
连接符 字段之间的字符拼接情况,用 || 进行拼接 -- select name || "的年龄是" || age from employee
对于数字字段可以使用 + - * / ()等运算符号 --- select salary , salary *1.6 + 30 from employee
去重复字段可以使用 distinct 放在 select 后 -- select distinct salary from employee
取别名 对于字段 我们可以给其取别名 三种方式 --select salary *12 as allsalary from employee
--select salary*12 "allsalary" from employee
--select salary *12 as "allsalary" from employee
from____ where 之间
通常我们写表名字 也可以用于嵌套语句 把表名换成一个select语句
where ___ 后面
where 用于写查询的条件,用于排序或过滤
比较运算符有 = 等于 >大于 >=大于等于 <小于 <=小于等于 <>不等于
其他的运算符 between... and ...(包括边界值) in like is null(空置判断)
逻辑运算符 and or not
而他们的优先级顺序为 算数运算符 > 连接符 > 比较符 > is [not] null [not] in like >[not] between > not > and > or
order by 字段名 asc 根据字段名的值 升序排列
order by 字段名 desc 根据字段名的值 降序排列
注意:字段可以有多个 各自带自己的升序或降序 先从第一个字段排序,相同则按照第二个
字段名还可以是取得别名
单行函数 一次处理一行返回一个结果
字符函数
大小写控制函数 lower(字段名) 字段名对应值全部小写
upper(字段名)字段名对应值全部大写
initcap(字段名) 字段名对应值首字母大写
------SELECT employee_id, last_name, department_id FROM employees
WHERE LOWER(last_name) = 'higgins';
字符控制函数
数值函数
日期函数