配套sql语句练习
基于教材:数据库系统概论第六版
总体
数据定义
表
定义基本表
例子:
索引
数据查询
单表
(1)选择若干列
to_char()
to_date()
to_number()
sysdate表示当前时间
计算加减时会把char转换为int
(2)选若干元组
where指定查询条件
字符匹配
(3)(4)
排序order by
函数 count sum max min avg
(5)
连接
等价于
select sno
from sc
where sc.cno='003'
intersect//并集
select sno
from sc
where sc.cno='005'
嵌套
子查询不能用order by
集合
数据更新
insert
update
delete
插入数据
插入单个元组
插入子查询结果
修改数据
删除数据
空值
视图
定义视图
查询视图
总结语句