幾個簡單的MYsql命令,數(shù)據(jù)表方面的,收藏自用.
1、只拷貝表結構,不拷貝數(shù)據(jù)
select * into b from a where 1<>1;
2、表數(shù)據(jù)遷移 表b已經(jīng)存在:
insert into b (d, e, f) select a, b, c from a;
表b原先不存在:
create table b (select a, b, c from a);
3、創(chuàng)建臨時表
創(chuàng)建臨時表的語法很簡單,臨時表存在內存中,會話結束即消失:
create temporary table a (...);
4、創(chuàng)建視圖
視圖屬于數(shù)據(jù)庫:
create view test.myView as select a, b from a;