1) 數(shù)據(jù)庫
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時,表明只是用查詢表的表定義帮匾,不插入數(shù)據(jù)啄骇。
4. Alter table table_name add column col type 注:列增加后將不能刪除。DB2中列加上后數(shù)據(jù)類型也不能改變瘟斜,唯一能改變的是增加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是數(shù)據(jù)可的一個邏輯存儲單元,用來將相關(guān)的數(shù)據(jù)結(jié)構(gòu)都組織到一起螺句。
2. create tablespace tbsname pagesize 4k managed by database using (file ‘file’ size)
3. Drop tablespace tbsname
4) 索引
1. 創(chuàng)建索引:create [unique] index idxname on tabname(co1…)
2. 刪除索引: drop index idxname
5) SQL語句
1. Delete from tablename where (condition)
2. Update 更新已有表的數(shù)據(jù)?
Update tabname set (co1=values 1, co2=values2,…) where (condition)
3. Insert into tablename (co1, co2,…) values (value1, value2, …)