len','F',10)
DB20000I SQL 命令成功完成。
db2 => select * from test1
CID CNAME SEX AGE
---------- -------------------- --------------
12082011 ellen F 10
12082111 albert M 15
12082119 chenlb M 24
3 条记录已选择。
3. 从其他表中获取数据
db2 =>insert into test1(cid , cname , sex , age) select empno,firstnme,sex,20 fromemployee where salary > 90000
DB20000I SQL 命令成功完成。
db2 =>select * from test1
CID CNAME SEX AGE
------------------------------ --- -----------
12082119 chenlb M 24
12082111 albert M 15
12082011 ellen F 10
000010 CHRISTINE F 20
000020 MICHAEL M 20
000030 SALLY F 20
000070 EVA F 20
7 条记录已选择。
4. 删除数据
1. 删除符合条件的数据:db2 => delete from test1 where length(trim(cid))=6
2. 清空表数据,我们常用的是delete from tablename,
还有另外一种方法,如下
Alter table tablename activate not logged initially withempty table:
db2 =>alter table test1 activate not logged initially with empty table
DB20000I SQL 命令成功完成。
db2 =>select count(*) from test1
1
-----------
0
1 条记录已选择。
5. 删除表
Drop table tablename
--the end--