Data replication between tables

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.