看你用的什么数据库:

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
 
posted on 2022-09-05 14:57  root-123  阅读(235)  评论(0编辑  收藏  举报