向兩張數(shù)據(jù)表中插入數(shù)據(jù)

2018-04-23 22:50 更新

  1. 在兩張數(shù)據(jù)表中,如何快速將一張數(shù)據(jù)表中的數(shù)據(jù)快速插入插入另一張數(shù)據(jù)表
    兩張表數(shù)據(jù)結(jié)構(gòu)一致的情況:  
insert into table_1 select * from table_2;

    兩張數(shù)據(jù)表結(jié)構(gòu)不一致的情況: 

insert into table_1 (col_name1, col_name2) .... select col_name1, col_name2 form table_2

    2.在創(chuàng)建表的時(shí)候,將已經(jīng)存在的數(shù)據(jù)表中的數(shù)據(jù)插入創(chuàng)建的表中。

create table table_name like table_exist select * from //如果不添加select * from table_exist(已經(jīng)存在的數(shù)據(jù)表),此時(shí)僅僅將table_exist的結(jié)構(gòu)復(fù)制給table_name 


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)