–创建数据表
CREATE TABLE RESUME_EXPIRENCE_INFO
(
RESUME_EXPIRENCE_ID NUMBER(10) PRIMARY KEY,
FOREIGN_RESUME_ID NUMBER(10),
EXP_COMPANY VARCHAR2(100),
EXP_POSITION_NAME VARCHAR2(100),
EXP_START VARCHAR2(100),
EXP_END VARCHAR2(100),
WORK_CONTENT VARCHAR2(4000)
)
–创建序列自增
CREATE SEQUENCE RESUMEEXPIRENCEINFO_SEQ – 建议使用表名+字段名+seq后缀
INCREMENT BY 1 – 每次加几个
START WITH 1 – 从1开始计数
NOMAXVALUE – 不设置最大值
NOCYCLE – 一直累加,不循环
NOCACHE – 不建缓冲区
–建立触发器
CREATE OR REPLACE TRIGGER RESUMEEXPIRENCEINFO_TRIGGER–触发器名称
BEFORE INSERT ON RESUME_EXPIRENCE_INFO–在这张表上建立
FOR EACH ROW
WHEN(NEW.RESUME_EXPIRENCE_ID IS NULL)–字段插入值为null,触发自增
BEGIN
SELECT RESUMEEXPIRENCEINFO_SEQ.NEXTVAL INTO:NEW.RESUME_EXPIRENCE_ID FROM DUAL;–获得自增值赋给主键
END;