DB2常用sql
- 创建表
Create table tab(
Id varchar(20) default ‘00’ not null
);
Comment on table Id is ‘序号’;
- 修改表字段 Alter table tab
增 Add column name varchar(20);
删 Drop column name varchar(20);
- 数据
增 insert into tab(id,name) values (‘01’,’zhangsan’);
删 delete from tab where id = ‘01’;
改 update tab name = ‘lisi’ where id = ‘01’;
查 select * from tab where id = ‘01’ with ur;
With ur -> DB2 中防止查询过程中有其他线程写入而导致的锁表或者写入失败
- 解锁表
有时执行删除字段->添加字段->删除字段的时候会锁表
Call sysproc.admin_cmd(‘reorg table tab’);
- 常用函数
- Case name when ‘zhangsan’ then ‘张三’ else ‘无’ end
- Coalesce(name,’’); 除null, null-> ‘’
- Count(*); 聚合函数
- **