creating trigger across different databases

后端 未结 3 1984
轮回少年
轮回少年 2021-01-14 21:25

Is there any way to create triggers on different databases? my requirement is like:-

 database: a1.db consist table: t1
 database:a2.db  consist table: t2


        
相关标签:
3条回答
  • 2021-01-14 21:39

    Looks like you need the MySQL equivalent of link servers (MSSQL) or dblink (Oracle). There is something called the FEDERATE storage engine:

    Check here

    0 讨论(0)
  • 2021-01-14 21:43

    What are the other databases you are using besides mysql? If Oracle is one of them, then you can create dblinks from Oracle to the other databases, and your trigger (running on Oracle) could use those dblinks to update the tables in the other databases.

    You can refer to this link for info on creating dblinks in Oracle: http://download.oracle.com/docs/cd/B12037_01/server.101/b10759/statements_5005.htm

    Also, see this link (How to create a DB link between two oracle instances) for another answer on stackoverflow.

    0 讨论(0)
  • 2021-01-14 22:00

    I can only speak for MySQL, but you should be able to do something like:

    CREATE TRIGGER ad_t1 AFTER DELETE ON `a1.db`.t1
    FOR EACH ROW
    INSERT INTO `a2.db`.t2 VALUES (...)
    
    0 讨论(0)
提交回复
热议问题