在Oracle中设置自动增长列
【实现步骤】
1. 创建表blog_info, 具有ID和title两个字段, 其中ID将设置为自动增长列;
2. 创建序列:
create sequence sq_blog_info start with 1 increment by 1 nomaxvalue nocycle cache 10;
create or replace trigger tg_blog_info before insert on blog_info for each row begin select sq_blog_info.nextval into :NEW.id from dual; --★注意: 此处的;是必须的 end;
insert into blog_info (title) values('a');