mysql 如何使用触发器并在dbeaver中实现它们?

new9mtju  于 2023-04-29  发布在  Mysql
关注(0)|答案(1)|浏览(167)

我已经为SQL数据库创建了触发器,但它将如何工作?

SQL

DELIMITER //
CREATE TRIGGER DeleteTransaction
ON Transaction
AFTER DELETE
AS
BEGIN
    INSERT INTO TransactionLog (TableName, Action, Timestamp)
    VALUES ('Transaction', 'DELETE', GETDATE())
END; //
DELIMITER ;

我想这个触发器运行时,一些数据是从交易表中删除。

hwamh0ep

hwamh0ep1#

CREATE TRIGGER DeleteTransaction
AFTER DELETE ON Transaction
FOR EACH ROW
    INSERT INTO TransactionLog (TableName, Action, `Timestamp`)
    VALUES ('Transaction', 'DELETE', GETDATE());

在BEGIN-END和DELIMITER重新分配中都不需要创建单语句触发器。

相关问题