开发者

mysql create a trigger in a database listening to table changes in a different database

开发者 https://www.devze.com 2023-01-14 05:18 出处:网络
something like: CREATE TRIG开发者_高级运维GER schema1.triggername AFTER INSERT ON schema2.table FOR EACH ROW

something like:

CREATE TRIG开发者_高级运维GER
       schema1.triggername
AFTER INSERT ON schema2.table
FOR EACH ROW
BEGIN
       ;
END;

ERROR 1435 (HY000): Trigger in wrong schema


The trigger needs to be in the same schema as the table you are inserting to, but it can access tables in other schemas.

Using your example:

CREATE TRIGGER schema2.triggername
AFTER INSERT ON schema2.the_table
FOR EACH ROW
  INSERT INTO schema1.the_table values (...);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号