Oracle新建表字段,如何使字段自增
oracle的自增需要依靠序列和触发器共同实现
比如 新建一张表
create table test
(id int primary key,name varchar2(10));创建一个序列
create sequence test_seq increment by 1 start with 1
minvalue 1 maxvalue 9999999999999 nocache order;触发器实现
create or replace trigger test_trigger
before insert on testfor each rowbegin select test_seq.Nextval into:new.id from dual;end;然后插入数据
insert into test (name) values ('张三');
作者:RichardCui
出处:https://www.cnblogs.com/yachao1120/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。该文章也同时发布在我的独立博客中-RichardCuiBlog。

浙公网安备 33010602011771号