DB2的基本sql操作

1. create语句

create table personinfo
(
  pno varchar(20) not null,
  pname varchar(20),
  primary key(pno)
);
2.  select 语句

select sname,num(sqy)
from stu
where sno>'121513'
group by sno

[distinct,max,concat,convert等函数]
或者

 select *
 from stu
 where sno in (或者=)
 (   
     select sno
     from person
     where  sno>‘121513’
 )


3. Insert语句(三种方法)

1)插入一行

insert into student (sno,sname) values('121513','zhayefei')

2)插入多行

insert into student(sno,sname) values ('123','zha'),('456','cha'),('789','Leo');

3)用select语句插入

insert into student(sno,sname)
select concat(sno,'10'),concat(sname,'v') 
from student 
where sno>'121513'
4. delete语句

delete 
from student 
where sno='121518'

5. update语句(两种方法)

update student set sname='Leo-zha' where sno='121513'
或者

update
(
    select * from student 
    where sno='121513'
)
set sname='zhayefei'
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值