oracle实现自增长
发布时间:2020-12-12 14:41:37 所属栏目:百科 来源:网络整理
导读:1.建表 create table test( id number(20) NOT NULL primary key,/*主键,自动增加,注意主键为number型*/ 2.建自动增长序列 Create Sequence addAuto_Sequence Increment by 1 -- 每次加几个 start with 1 -- 从1开始计数 nomaxvalue -- 不设置最大值,设置
1.建表 create table test( id number(20) NOT NULL primary key,/*主键,自动增加,注意主键为number型*/ 2.建自动增长序列 Create Sequence addAuto_Sequence 3.建触发器 Create trigger addAuto before insert on test(表名) for each row /*对每一行都检测是否触发*/ begin select addAuto_Sequence.nextval into:New.id from dual; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |