oracle和sqlserver比較

來源:互聯網
上載者:User

1、oracle建表時只提供串聯刪除,sqlserver提供串聯刪除和更新。雖然建立主外鍵關係之後,主表的主索引值不應該經常修改,可有時候有這種需求。)刪除時oracle提供3種選擇set null,級聯,什麼都不幹),sqlserver除了那3種還提供了設定預設值。


2、oracle不提供主鍵自增,需要用序列加觸發器實現,sqlserver提供主鍵自增[proId] [int] IDENTITY(1,1) NOT NULL,將標識規範裡的是標示標示增量標示種子設定後主鍵就自動產生了。

添加序列:

create sequence seq_depid

minvalue 1

maxvalue 99999

start with 1

increment by 1

nocache;

建觸發器:

create or replace trigger trg_depid

before insert on dep

for each row

when (new.depid is null)

begin

select seq_depid.nextval into :new.depid from dual;

end trg_depid;


本文出自 “愛IT” 部落格,請務必保留此出處http://5563447.blog.51cto.com/5553447/1305044

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.