Oracle测试脚本——创建触发器

51 阅读1分钟
CREATE TABLE test.test_log (
    id NUMBER,
    operation VARCHAR2(10),
    operation_date TIMESTAMP,
    old_value VARCHAR2(100),
    new_value VARCHAR2(100)
);

CREATE TABLE test.test_table(id int);

CREATE OR REPLACE TRIGGER test.trg
AFTER INSERT ON test.test_table
FOR EACH ROW
BEGIN
    INSERT INTO test.test_log (operation, operation_date, new_value)
    VALUES ('INSERT', SYSTIMESTAMP, :NEW.column_name);
END;