一、多行函数又称组合函数(Group Functions)、聚合函数
1、 Types of Group Functions
avg、count、max、min、stddev、sum、variance
avg 求平均数
select avg(nvl(列1,0)) from 表1
count求行数
在where条件中不允许使用聚合函数,但可以使用having avg(列1)>1000
having所起的作用和where一样
二、子查询Subqueries
查询前10行数据
oracle: select * from 表名 where rownum<=10;
sql: select top 10 * from 表名
单行子查询
select * from 表1 where 工资列1>(select avg(工资列1) from 表1)
多行子查询
select * from 表1 where 工资列1 in(select min(工资列1) from 表1 group by 部门列)
三、自定义变量
set verify on/off
show all
help show/set
column lie justify left
四、数据操作语句
1、insert插入语句
向表2里插入数据
oracle:insert into (select 列1,列2 from 表2)values('XXX','XXX');
oracle/sql:insert into(列1,列2)values('XXX','XXX');
从另一个表里复制数据
oracle/sql:insert into 表(列1,列2)select 列1,列2 from 表2
2、update语句
都为: update table set column1='...'[ ,column2='...'] where ...
嵌入子查询的修改
update table set column1=(select column2 form table where columnid=1) where column1='...'
delete删除语句
delete [from] table [where condition]
merge 合并语句
oracle:
merge into 表1 a using 表2 b on (a.id=b.id)
when matched then
update set
a.name=b.name,
a.other=b.other
when not matched then
insert values(b.id,b.name,b.other);
sql:合并insert,update
方法1:
declare @ROWCOUNT int
set @ROWCOUNT=(select count(*) from tb_name where name1='5')
if @ROWCOUNT!=0
update tb_name set name2='55555555' where name1='5'
else
insert into tb_name(name1,name2) values('5','插入')
方法2:
update tb_name set name2='55555555' where name1='6'
if @@ROWCOUNT=0
insert into tb_name(name1,name2) values('6','插入')
五,事务: 隐式、显式的事务
commit提交事务
rollback 回滚事务
locking锁
对并发性系统自动加锁,事务提交后、或回滚后自动解锁。
oracle,学习笔记
更新日志
- 群星《前途海量 电影原声专辑》[FLAC/分轨][227.78MB]
- 张信哲.1992-知道新曲与精丫巨石】【WAV+CUE】
- 王翠玲.1995-ANGEL【新艺宝】【WAV+CUE】
- 景冈山.1996-我的眼里只有你【大地唱片】【WAV+CUE】
- 群星《八戒 电影原声带》[320K/MP3][188.97MB]
- 群星《我的阿勒泰 影视原声带》[320K/MP3][139.47MB]
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]