mysql在数据库中创建一个触发器,监听不同数据库中的表更改

时间:2022-06-15 21:56:16

something like:

喜欢的东西:

CREATE TRIGGER
       schema1.triggername
AFTER INSERT ON schema2.table
FOR EACH ROW
BEGIN
       ;
END;

ERROR 1435 (HY000): Trigger in wrong schema

错误1435 (HY000):在错误的模式中触发

1 个解决方案

#1


3  

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 (...);

#1


3  

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 (...);