看你用的什麼資料庫: Sql server : select * into table_new from table_old ; 複製結構和資料 select * into table_new from table_old where 1=2;只複製結構 Oracle: create table table_new as select * from table_old;複製結構和資料 create table table_new as select * from table_old where 1=0;只複製結構 DB2: --複製表結構 create table table_name_new as (select * from table_name_old) definition only; --插入資料 insert into table_name_new (select * from table_name_old); MySql: ----- 複製表結構及資料到新表 CREATE TABLE 新表 SELECT * FROM 舊錶 ----- 只複製表結構到新表 CREATE TABLE 新表 SELECT * FROM 舊錶 WHERE 1=2
看你用的什麼資料庫: Sql server : select * into table_new from table_old ; 複製結構和資料 select * into table_new from table_old where 1=2;只複製結構 Oracle: create table table_new as select * from table_old;複製結構和資料 create table table_new as select * from table_old where 1=0;只複製結構 DB2: --複製表結構 create table table_name_new as (select * from table_name_old) definition only; --插入資料 insert into table_name_new (select * from table_name_old); MySql: ----- 複製表結構及資料到新表 CREATE TABLE 新表 SELECT * FROM 舊錶 ----- 只複製表結構到新表 CREATE TABLE 新表 SELECT * FROM 舊錶 WHERE 1=2