2011-04-07 67 views
2

如何创建一个重复表中没有任何数据如何创建一个重复表中没有任何数据

旧表名 - 学生

newtablename - student1

PLZ告诉我exat查询

感谢, 丘吉尔..

+0

可能重复:HTTP://计算器.com/questions/4616707/sql-server-copy-full-table-definition – 2011-04-07 21:35:31

回答

5
SELECT TOP 0 * INTO student1 FROM student 
+1

缺点是它不会复制索引,PK,FK等。下面是如何复制完整的表结构:http:// dba.stackexchange.com/questions/18059/copy-c完整结构的表 – 2015-11-26 19:18:36

3
select * into student1 from student where 1=0 
+1

,但'student1'不包含索引,约束和其他东西,这是'学生'表模式的一部分。 – 2011-04-07 21:40:51

1

SELECT * 到student1 从学生那里 1 = 2

这将让你的栏目, 但索引和其他对象 需要脚本 与某种类型的数据库工具。

0
create table newtable as select * from oldtable where clause 
+0

这不会帮助操作...它复制数据,也不会复制像自动增量 – NineCattoRules 2017-01-17 15:41:29

0

首先,你可以通过整个表复制:

select * into (your_table_name) from student 

复制整个表后,可以通过运行删除数据:

truncate table (your_table_name); 
相关问题