★☆

★☆
posts - 0, comments - 0, trackbacks - 0, articles - 80
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

DB2基本增删改查

Posted on 2009-04-16 09:25 阅读(488) 评论(0)  编辑  收藏 所属分类: DB2学习

                                                       DB2学习笔记
1) 向数据库中插入一条记录
insert into test1(id,name) values('001','aaaa')

2) 向数据库中插入多条记录
insert into test1
select * from test

3)修改数据库中的数据
     update test t set t.name=t.id

   4)删除数据库中的记录
    delete from test t where t.id='001'

   5)取出前10条数据
      select * from test  fetch first 10 rows only
    中间可以加where条件,select * from test where id='001' fetch first 10 rows only

   6)左外连接、右外连接和全连接
        左外连接:
        select * from test t1
     left outer join test1 t2 on t1.id = t2.id;
       右外连接:
     select * from test t1
     right outer join test1 t2 on t1.id = t2.id;
       全连接:
        select * from test t1
      full outer join test1 t2 on t1.id = t2.id;

7)修改表结构
添加一列
alter table ods.ods1 add column riqi date
alter table ods.ods1 add column riqi2 date not null default current date
删除一列
alter table ods.ods1 drop column riqi3


只有注册用户登录后才能发表评论。


网站导航: