我试图创建一个触发器,在插入表后,将数据插入到不同的表中。但是显示语法错误,我不知道错误在哪里:
CREATE TRIGGER insertDumpData ON users
FOR INSERT
AS
BEGIN
INSERT INTO attachments ("1", "sds", "hi");
END;
哦,我看到您正在 mySQL 上尝试 SQL Server 语法。试试这个:
delimiter |
CREATE TRIGGER insertDumpData BEFORE INSERT ON users
FOR EACH ROW BEGIN
INSERT INTO attachments values ('1', 'sds', 'hi');
END;
|
不要忘记在过程周围添加分隔符
delimiter |
CREATE TRIGGER insertDumpData ON users
...
INSERT INTO attachments select "1", "sds", "hi";
...
|
正如迭戈在他的回答中提到的那样:更正您的插入语句。
缺少“价值”
CREATE TRIGGER insertDumpData ON users
FOR INSERT
AS
BEGIN
INSERT INTO attachments values ("1", "sds", "hi");
END;