自动增加字topicId
CREATE TABLE t_topic (
topicId NUMBER(18,0) NOT NULL , -- 主题ID
topicTitle VARCHAR2(100) NOT NULL , -- 主题名
topicContent varchar2(2000) NOT NULL , -- 主题内容
....
PRIMARY KEY (topicId)
);
Create Sequence t_topic_Id_sequence --主题序列
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOCYCLE;
CREATE OR REPLACE TRIGGER t_topic_Id_trigger //触发器
BEFORE INSERT
ON t_topic
FOR EACH ROW
DECLARE
newId NUMBER(18,0);
BEGIN
SELECT t_topic_Id_sequence.nextval INTO newId FROM dual;
:new.topicId := newId;
END;