oracle创建表,表序列,触发器
oracle创建表,表序列,触发器
创建表
CREATE TABLE "JCMS_ADVERT"
( "ID" INTEGER NOT NULL ENABLE,
"SITEID" INTEGER,
"NAME" VARCHAR2(150 CHAR) NOT NULL ENABLE,
"UPDATETIME" DATE,
PRIMARY KEY ("ID")
);
创建表序列
create sequence seq_advert minvalue 1 maxvalue 9999999999999999999999999999 increment by 1 start with 1 cache 20 noorder nocycle ;
创建触发器
create or replace trigger tr_advert
before insert on jcms_advert
for each row
begin
select seq_advert.nextval into :new.id from dual;
end;
插入记录
insert into jcms_advert (siteid,name, updatetime) values (1,'头部广告', sysdate);
查询记录
select * from jcms_advert;