greenZ

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

--insert多行记录
insert into <table>(<column_list>) values(<value_list1>)[,(<value_list2>),……];
 
--select
1.with ur
select * from <table>;  --会锁表
select * from <table> with ur;  --不会锁表
 --查看锁
select * from sysibmadm.locks_held with ur;
 
2. fetch first <num> rows only
select * from <table>
order by <column>|rand()
fetch first <num> rows only;  --取前几行记录
 
3.分页查询
select * from (
select
t.*,
rownumber() over(order by t.<column>  asc ) as rn,
rownumber() over(order by  order of <table>) as rn2,
rownumber() over(order by  1) as rn3
from <table>
) tt
where tt.rn >= 6 and tt.rn <= 10;  
 
 
4.values相当于匿名表
select t.* from  (values(1,'aa'),(2,'bb')) as t;
select t.* from  (values(1,'aa'),(2,'bb')) as t(c1,c2);
 
 
 
 
posted on 2017-03-06 21:31  绿Z  阅读(246)  评论(0)    收藏  举报