1.建表:
(1)創建基本表二者是一致的
mysql:create table person(name varchar(10),age int)
db2: 同上。
(2)mysql支持在創建表的時候指定引擎和字符集,但是db2不支持
2.查看表
mysql:show tables(查看所有表)show create table person(看單個表)
db2: select name from sysibm.systables where type=’T’and creator =’db2inst1’
在當前表模式下查找所有表:select tabname from syscat.tables where tabschema =current schema.
3.查看表結構
mysql: desc person
db2:select * from sysibm.columns where table_schema=current schema and table_name=’ams_wlck’;
4.刪除表
mysql: drop table t1
db2:同上
5.修改表結構
(1)添加表字段
mysql:alter table person add Chinese int(after id);
db2:alter table person add Chinese int; 注意:db2不支持after等關鍵字以在指定位置添加字段
(2)刪除字段
mysql: alter table stu drop id;
db2:同上。
(3)修改字段
mysql:
1) 修改字段名和類型
alter table stu change name stu_no int;
2) 修改字段類型和位置
alter table stu modify stu_no varchar(10) after math;
db2: 不允許修改表字段。
6.對數據的基本操作 二者基本一致,如果涉及到翻頁mysql一般是limit關鍵詞,而db2是fetch關鍵詞,用法也不一樣。db2也支持偽列。