ech*_*aze 3 oracle constraints sequence
有没有办法约束一个列(比如说"ID")来跟随一个创建的序列(比如"ID_SEQ")?
如果没有自动约束,手动插入可能会使整个序列失控.可以做些什么来解决这个问题?只需拨打NextVal两次?
您可以使用触发器来完成此操作.例:
create or replace trigger product_insert before insert on product for each row begin
select id_seq.nextval
into :new.product_id
from dual;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
377 次 |
| 最近记录: |