SQL语句如下:
--建表myMessage
create table myMessage( myID number(10) not null primary key,
name varchar2(40) not null,
sf varchar2(40) not null,
hobby varchar2(40) not null,
url varchar2(300) null,
worktime varchar2(40) not null);
--创建序列my_autoinc_seq:
create sequence my_autoinc_seq
minvalue 1
maxvalue 99999999
start with 1
increment by 1
nocycle
nocache
order;
--创建触发器my_autoinc_tg:
create or replace trigger my_autoinc_tg
before insert on myMessage for each row --表示在插入一行数据之前
begin
select my_autoinc_seq.nextval into :new.myID from dual; --myID即主键 ,dual表示伪表
end my_autoinc_tg;
--test
insert into myMessage values('','cn','sxs','play','indi.php','day');
insert into myMessage values('','em','sxs','play','indi.php','day');
select * from myMessage