当前位置: 代码迷 >> SQL >> oracle中创办Sequence和Trigger的SQL语句
  详细解决方案

oracle中创办Sequence和Trigger的SQL语句

热度:29   发布时间:2016-05-05 14:20:10.0
oracle中创建Sequence和Trigger的SQL语句

//建Sequence

create sequence STUDENT_S
minvalue 1
maxvalue 999999999999999999999999
start with 1
increment by 1
cache 20;


//建表
CREATE TABLE STUDENT
(
?? ID INTEGER,
?? "NAME" VARCHAR2(20),
?? ADDRESS VARCHAR2(40),
?? AGE INTEGER
)


//建Trigger
CREATE OR REPLACE TRIGGER INSERTSTUDENTID
BEFORE INSERT ON STUDENT
FOR EACH ROW
BEGIN
??? SELECT STUDENT_S.NEXTVAL INTO :NEW.ID FROM DUAL;
END;

  相关解决方案