create table 表名 as select 與 select * into


一、新表不存在

1、create table cs as select * from t_aly_il_result  ---備份結構和數據

      

 

 2、create table cs1 as select * from t_aly_il_result where 1 = 0  ---復制結構

 

3、create table cs2 as select up_inst_id,aly_layer from t_aly_il_result --復制部分字段

 

二、新表已存在(以下必須先創建表)   

    前提條件:create table cs3 as select * from t_aly_il_result where 1 = 0 --表結構已存在

1、復制數據

select * from cs3 ---沒數據的表
insert into cs3 select * from t_aly_il_result; --復制數據到新表

 2、select * into new_table from old_table;

3、select * into new_table from old_table where 1=2;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM