Home > database > When update A field in A table, table B content copied again change A field insert table B
When update A field in A table, table B content copied again change A field insert table B
Time:10-03
A table A field two fields three Q W 0 E R 0 Table B Four field five field. A C 0 G H 0 When the three fields in the table A update to 1, table of contents shows as follows: A table A field two fields three Q W 1 E R 1 Table B Four field five field. A C 0 G H 0 A C 1 G H 1 Pray god help,
CodePudding user response:
SQL> SQL> The create table a (c1 varchar (10), c2 varchar (10), the c3 int); The Table created SQL> The create table b (c1 varchar (10), c2 varchar (10), the c3 int); The Table created SQL> Create the trigger tri_a_up 2 before the update on a 3 for each row 4 the begin Insert into 5 b values (: new c1, : new, c2, : new, c3); 6 the end; 7/ The Trigger created SQL> Insert into a values (' a ', 'B', 0). 1 row inserted SQL> Insert into a values (' C ', 'D', 0). 1 row inserted SQL> Update a set c3=1; 2 rows updated SQL> Select * from b; C1 C2 C3 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- B, 1 C D 1 SQL> Drop table a purge; Table dropped SQL> Drop table b purge; Table dropped
SQL>
CodePudding user response:
Pro, you the contents of this seems to be and I said a little discrepancy