DB2的基本sql操作

来源:互联网 发布:平面图设计软件下载 编辑:程序博客网 时间:2024/04/30 03:21

1. create语句

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

select sname,num(sqy)from stuwhere 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'