1) 数据库
1. Create database
2. Drop database
2) 表
1. Create table tab-name
2. Create table table-new like tab-old
3. Create table table-new as select co1, co2…… from table-old definition only
在sql建表时,使用create table table_name as select ... definition only时,表明只是用查询表的表定义,不插入数据。
4. Alter table table_name add column col type 注:列增加后将不能删除。DB2中列加上后数据类型也不能改变,唯一能改变的是增加varchar类型的长度。
5. Alter table tab_name add primary key (col) 增加主键
6. Alter table tab_name drop primary key (col) 删除主键
7. Drop table tab_name 删除表
3) 表空间
1. Tablespace是数据可的一个逻辑存储单元,用来将相关的数据结构都组织到一起。
2. create tablespace tbsname pagesize 4k managed by database using (file ‘file’ size)
3. Drop tablespace tbsname
4) 索引
1. 创建索引:create [unique] index idxname on tabname(co1…)
2. 删除索引: drop index idxname
5) SQL语句
1. Delete from tablename where (condition)
2. Update 更新已有表的数据
Update tabname set (co1=values 1, co2=values2,…) where (condition)
3. Insert into tablename (co1, co2,…) values (value1, value2, …)