Step 1: Create a table in database TW
Conn system/passwd @ TW;
Create user test identified by test;
Grant connect to test;
Grant create table to test;
Alter user test quota 1 m on users;
----------------------
Conn test/test @ TW;
Create Table Test (name varchar2 (20 ));
Insert into test values ('from _ TW ');
Step 2: Create a table in database tw1
Conn system/passwd @ tw1;
Create user test identified by test;
Grant connect to test;
Grant create table to test;
Alter user test quota 1 m on users;
Grant create trigger to test;
--------------------------
Conn test/test @ tw1;
Create Table Test (name varchar2 (20 ));
Insert into test values ('from _ tw1 ');
Step 3: Create a dblink and trigger in tw1
Create public database link totw connect to test identified by test using 'tw ';
---------------------
Create or replace trigger write_tw_test
After insert on Test
Referencing old as old New as new
For each row
Begin
Insert into Test. Test @ totw (name) values (: New. Name );
Dbms_output.put_line ('--- inserting ---');
End;
/
Step 4: Demo
Step 5: Conclusion
The trigger operation and trigger event belong to the same transaction. The trigger and trigger event are committed and rolled back together (same as dblink)
A row-Level Trigger is triggered when a row changes. Only after the trigger completes its operations will the subsequent events continue (waiting for the trigger to complete)
Step 6: test whether the trigger works in dblink (TW)
Create or replace trigger read_insert
After insert on Test
For each row
Begin
Insert into test1 values ('read _ from_tw1 ');
End;
/-- Work
-- It is easy to wait for the trigger to complete all operations, and wait for the lock