Oracle觸發器聯合唯一約束

2022-03-12 09:18:21 字數 1312 閱讀 1607

oracle支援可為空字端的唯一約束呢?下面就是用觸發器作出的限制語句,僅供參考:

create or replace trigger tg_completion_test

before insert or update on bz_funds_voucher

for each row --行觸發,沒有本行則為語句級觸發

declare

too_many exception;

pragma exception_init(too_many, -20001);

v_exist_count number := 0;

begin

select count(*)

into v_exist_count

from bz_funds_voucher t

where t.document_code is not null

and t.territory_code = :new.territory_code

and t.document_code = :new.document_code ;

if v_exist_count > 0 then

end if;

end;

create or replace trigger tg_bz_rent_payment_voucher

before insert or update on bz_rent_payment_voucher

for each row --行觸發,沒有本行則為語句級觸發

declare

too_many exception;

pragma exception_init(too_many, -20002);

v_exist_count number := 0;

begin

select count(*)

into v_exist_count

from bz_rent_payment_voucher t

where

t.collection_way not in ('轉款', '優惠活動')

and t.create_date > to_date('2015-01-01', 'yyyy-mm-dd')

and t.serial_no is not null

and t.reserve_code is null

and t.serial_no = :new.serial_no ;

if v_exist_count > 0 then

end if;

end;

MySQL 新增唯一約束和聯合唯一約束

在mysql資料庫中,經常會碰到由於業務需要新增唯一鍵約束,唯一鍵約束,可以在乙個列上新增約束,也可以在多個列上新增唯一約束。1.建表時加上唯一性約束 create table t user id int 11 notnull auto increment username varchar 18 n...

oracle違反唯一約束

報錯資訊 nested exception is org.hibernate.exception.constraintviolationexception could not execute statement 背景 修改原有的邏輯,取消掉某個欄位的唯一約束。框架 spring data jpa 1...

唯一約束和檢查約束(oracle)

1.唯一約束和主鍵區別 主鍵字段值必須是非空的 唯一約束允許有乙個空值 2.唯一約束關鍵字 unique 3.在建立表時設定唯一約束 constraint constraint name unique column name 4.在修改表新增唯一約束 add constraint constrain...