Data replication between tables
We can use insert between two tables to implement simple replication (the two tables have the same structure). The example is as follows:
SQL> create table T (
2 tid number (4 ),
3 tname varchar2 (10) default 'abc ',
4 tbirthday date default sysdate );
The table has been created.
SQL> insert into T values (1, 'aaa', '05-January 1, June-89 ');
One row has been created.
SQL> insert into T values (2, 'bbb ', '05-January 1, June-89 ');
One row has been created.
SQL> insert into T (tid) values (3 );
One row has been created.
SQL> select * from T;
TID TNAME TBIRTHDAY
----------------------------------
1 aaa 05-6 months-89
2 bbb 05-6 months-89
3 abc 21-3-15
As shown above, table T has three pieces of data. We can create another table T2 to make it have the same structure as table T.
SQL> create table t2 (
2 tid number (4 ),
3 tname varchar2 (10) default 'aaa ',
4 tbirthday date default sysdate );
The table has been created.
SQL> insert into t2 select * from t;
3 rows have been created.
SQL> select * from t2;
TID TNAME TBIRTHDAY
----------------------------------
1 aaa 05-6 months-89
2 bbb 05-6 months-89
3 abc 21-3-15