表之間的資料複製,資料複製

來源:互聯網
上載者:User

表之間的資料複製,資料複製

我們可以在兩張表之間使用insert實現簡單的複製,(兩張表的結構要相同)執行個體如下:

SQL> create table T(

  2  tid number(4),
  3  tname varchar2(10) default 'abc',
  4  tbirthday date default sysdate);

表已建立。

SQL> insert into T values(1,'aaa','05-6月-89');

已建立 1 行。

SQL> insert into T values(2,'bbb','05-6月-89');

已建立 1 行。

SQL> SQL> insert into T (tid) values(3);

已建立 1 行。

SQL> select * from T;

       TID TNAME      TBIRTHDAY
---------- ---------- --------------
         1 aaa        05-6月 -89
         2 bbb        05-6月 -89
         3 abc        21-3月 -15

如上所示,T表中有三條資料,我們再建另一張T2表,使它的結構和T相同。


SQL> create table t2(
  2  tid number(4),
  3  tname varchar2(10) default 'aaa',
  4  tbirthday date default sysdate);

表已建立。


SQL> insert into t2 select *from t;

已建立 3 行。

SQL> select * from t2;

       TID TNAME      TBIRTHDAY
---------- ---------- --------------
         1 aaa        05-6月 -89
         2 bbb        05-6月 -89
         3 abc        21-3月 -15

相關文章

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.