DB2个人学习笔记

按条件返回记录

select bank_id from table1 where SEQ = 419;

返回前十条记录

select * from table1 where id <> '03090000' fetch first 10 rows only;

返回10-20的记录

select * from table1 where id <> '03090000' and id not in (select id from table1 where id <> '03090000' fetch first 10 rows only) fetch first 10 rows only;

like及count

select count(*) from table1  where id <> '03090000' and name like '%测试%'; "%" 可用于定义通配符(模式中缺少的字母)

select * from tbl_ccp_bank_stat_inf where bank_nm not like '%农%';
distinct

select distinct name from table1; 

between和like、or、oder by

select *  from table1 where id between '14040000' and '14385500' and name like '%农%';

select *  from table1 where id between '14040000' and '14385500' or name like '%农%' order by id;

插入数据

insert into table1 values(624,'11111111','个人',0,0,'20130314','6','1') ; 其中,624和0、0是Integer,带' ' 的为char和varchar

更新数据

update  table1  set seq = 622,id='22222222',name='人民' where seq = 611;
删除数据

delete from  table1   where seq = 633;

通配符

select * from  table1 where name  like '_1%';  _代表一个字符
in

select *  table1  where name in('农业','技术');


你可能感兴趣的:(DB2个人学习笔记)