db2和mysql語法分析異同點


 

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也支持偽列。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM