DROP SEQUENCE seq_chat_group_Id;
DROP SEQUENCE seq_chat_msg_id;
CREATE SEQUENCE seq_chat_group_Id;
CREATE SEQUENCE seq_chat_msg_id;
CREATE OR REPLACE TRIGGER autoIncrementMsgPK_trigger
BEFORE INSERT ON chat_messages
FOR EACH ROW WHEN (new.msgId IS NULL)
BEGIN
SELECT seq_chat_msg_id.nextval INTO:new.msgId FROM dual;
END;
CREATE OR REPLACE TRIGGER autoIncrementGroupPK_trigger
BEFORE INSERT ON chat_group
FOR EACH ROW WHEN (new.groupId IS NULL)
BEGIN
SELECT seq_chat_group_Id.nextval INTO:new.groupId FROM dual;
END;
create oracle DB auto increment PK trigger
最新推荐文章于 2024-07-24 07:09:51 发布