<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    DANCE WITH JAVA

    開發出高質量的系統

    常用鏈接

    統計

    積分與排名

    好友之家

    最新評論

    對比mysql oracle db2 的部分ddl語法

    建表、刪除表:mysql  oracle  db2基本相同
    create table test(id integer,name varchar(20),address varchar(20));
    (oracle 多用varchar2,但也支持varchar)
    drop table test;

    但是修改表就有很大的不同了,如下:

    1,增加列:相同
    alter table test add mail varchar(128);

    2,刪除列:
    oracle 與mysql相同:alter table test drop column mail;
    db2              :不提供刪除列功能(解決辦法是刪除表,重建)

    3,更改列名
    oracle : alter table test rename column mail to mail2;
    mysql  : alter talbe test change mail mail2 varchar(128);
    db2    : 不提供更改列名功能(解決辦法同刪除,或者通過建立一個新視圖解決)

    4,更改列類型
    oracle :alter table test modify column (mail2 integer);
    mysql  :alter table test modify column mail2 integer;
    db2    :alter table test alter mail varchar(256) 只可以加寬,不能更改類型

    5,更改列的限制(主鍵、非空)
    db2   :alter table test alter mail null/not null;
    mysql :alter table test modify mail2 varchar(29) not null;
    oracle:alter table test modify mail2 null/not null;

    關于db2不提供解決辦法,參考這里
    http://www-128.ibm.com/developerworks/cn/db2/library/techarticles/0207adamache/0430_adamache3.html
    截取部分原文
    -------------------------------------------------------------------------------
    DROP COLUMN:DB2 不允許您刪除一個列。我可以想到您希望刪除列的三個理由:
    回收空間:如果您希望這樣做,可以導出您希望保存的數據,刪除那個表,用您需要的那些列重新創建表,然后裝入
    這個表。這是否代價高昂?當然是,但是回收空間需要這樣或者 REORG TABLE。這些本來就是代價高昂的操作。

    這個列不再是行的邏輯部分:例如,您意識到您的雇員可能有兩個地址,并且停止跟蹤雇員(employee)表中的地址
    (雇員表和雇員地址(employee_address)表之間現在有 n:m 關系)。在雇員表上創建一個不包含地址列的視圖。
    如果您真的要用新奇的方法,可以使用 RENAME TABLE 命令給基表一個新的名稱,然后將原始表名作為該視圖的
    名稱。您的視圖也可以連接雇員表中的有用列和從雇員地址獲得的地址。現在我們回到了關系的正道。

    列變寬了。如果它是 VARCHAR,那您運氣不錯。DB2 允許您將 VARCHAR 列最多加寬至表空間(tablespace)
    中定義的頁大小寬度(缺省的 4K 頁大小為 4,005,而在 32K 頁上最多為 32,672):
    ---------------------------------------------------------------------------------

    但是過程中問一個朋友,得到的結論是可以改,矛盾啊繼續找資料:
    http://www-1.ibm.com/support/docview.wss?uid=swg21004049
    部分截取原文
    -------------------------------------------------------------------------------
    In DB2® Universal Database™ (DB2 UDB) Version 8.2, the Control Center automates
    the process of altering a table where recreation of the table is necessary,
    saving the user from performing a lengthy set of manual steps. Specifically,
    the Control Center will automate the following operations: rename a column;
    drop a column; change the data type of a column; change the length, scope,
    or precision values for a column; change whether a column is nullable. If necessary,
    the table that is being changed will be dropped and recreated, and DB2 UDB will
    help the user restore any dependent objects and transform the existing data into
    the target data type of each remaining column.
    You cannot drop a column in DB2 UDB Version 8.1 or earlier. There are work-arounds.
     For example, you can increase the width of a VARCHAR column up to the largest
     column width supported by the page size used by the table (4005 bytes by default,
      but possibly as large as 32672 byes on 32K pages). The page size is chosen
      when the table space is created. To handle more complex changes:
      -----------------------------------------------------------------------------
      原來DB2 UDB Version 8.1 or earlier不支持,8.2才開始支持。

     

    posted on 2006-11-22 15:41 dreamstone 閱讀(2522) 評論(0)  編輯  收藏 所屬分類: 片段

    主站蜘蛛池模板: 亚洲精品韩国美女在线| 亚洲日韩精品国产3区| 亚洲国产精品久久久久婷婷老年 | 浮力影院第一页小视频国产在线观看免费| 日韩精品视频免费在线观看| 亚洲成a人片77777kkkk| 亚洲日韩看片无码电影| 四虎免费在线观看| 亚洲AV无码成人精品区蜜桃 | 黄床大片30分钟免费看| 亚洲第一网站免费视频| 国产成人亚洲综合| 亚洲男同gay片| 永久在线毛片免费观看| 香蕉97碰碰视频免费| 亚洲精品A在线观看| 亚洲av永久中文无码精品| 97碰公开在线观看免费视频| 亚洲精品无码午夜福利中文字幕| 狠狠综合亚洲综合亚洲色| 中文字幕无码成人免费视频| 亚洲成AV人片在线观看| 精品无码人妻一区二区免费蜜桃| 国产成人无码综合亚洲日韩| 99免费观看视频| 久久久影院亚洲精品| 精品熟女少妇aⅴ免费久久| 国产精品冒白浆免费视频| 天天爽亚洲中文字幕| 欧洲一级毛片免费| 久久精品国产亚洲AV高清热| a级毛片在线免费| 亚洲女人被黑人巨大进入| 国产日韩AV免费无码一区二区| 久久久久亚洲av毛片大 | 成人A毛片免费观看网站| 亚洲国产精品成人| 特级毛片全部免费播放a一级| 国产成人亚洲精品青草天美| 欧洲精品成人免费视频在线观看 | 性感美女视频在线观看免费精品|