如何在SQL中使用触发器

时间:2018-12-14 05:40:36

标签: sql oracle plsql database-trigger

CREATE TABLE table_001(
Day_date date
);

CREATE TABLE table_002(
new_Day_date date
);



CREATE OR REPLACE TRIGGERS trigger
AFTER INSERT ON table_001
FOR EACH ROW
BEGIN
    INSERT INTO table_002 VALUES(SYSDATE)
END;

2 个答案:

答案 0 :(得分:0)

您有一些语法错误。它不是不是“触发器”。另外,提供有效的触发器名称。插入后缺少分号。

   CREATE OR REPLACE TRIGGER trigger_name
    AFTER INSERT ON table_001
    FOR EACH ROW
    BEGIN
        INSERT INTO table_002(new_Day_date) VALUES(SYSDATE);
    END;
    /

答案 1 :(得分:0)

CREATE OR REPLACE TRIGGER trigger_name
AFTER INSERT ON table_001
FOR EACH ROW
BEGIN
    INSERT INTO table_002 VALUES(SYSDATE);
END;