MySQL表結構復制、表數據遷移以及臨時表、視圖創建


1、只拷貝表結構,不拷貝數據

select * into b from a where 1<>1;

 

2、表數據遷移

      表b已經存在:

insert into b (d, e, f) select a, b, c from a;

     表b原先不存在:

create table b (select a, b, c from a);

 

3、創建臨時表

      創建臨時表的語法很簡單,臨時表存在內存中,會話結束即消失:

create temporary table a (...);

 

4、創建視圖

      視圖屬於數據庫:

create view test.myView as select a, b from a;


免責聲明!

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



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