Creating a trigger in different databases

Is there a way to create triggers for different databases? my requirement: -

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

now i need to use the trigger on t1 (whenever any delete and update operation) happens on t1, the value should be inserted in t2.

waiting for your feedback ...

+2
source share
3 answers

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 (...) 
+3
source

What other databases do you use besides mysql? If Oracle is one of them, you can create dblinks from Oracle to other databases, and your trigger (running on Oracle) can use these dblinks to update tables in other databases.

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

Here is the dblinks specific link from Oracle to mysql: http://www.dba-oracle.com/t_how_create_database_link.htm

+1
source

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

Check here

0
source

Source: https://habr.com/ru/post/1432041/


All Articles