1、建表
create table blog(blogId number(10) not null primary key, blogName varchar2(40) not null, username varchar2(10) null);
2、建序列:用于表的主键
create sequence blog_autoinc_seq minvalue 1 maxvalue 999999999 startwith 1 increment by 1 nocycle order;
3、建触发器:建立表之前,先检索序列的下一位的值用于插入到表的blogId
create or replace trigger blog_autoinc_tg
before insert on blog for each row
begin select blog_autoinc_seq.nextval into :new.blogId from dual;
end blog_autoinc_tg;
<