如何根据另一个表的模式创建一个空的临时表?

7
有没有一种惯用的方法来做到这一点?
3个回答

26
select * into x_temp from tbl where 1 = 0

2

这在大多数数据库中都可以使用:

create table blah as
select * from foo where 1=0

请注意,这不会复制主键、索引等。

1
select top 0 * into temp_table from table

这是我通常使用的方法,但我也喜欢Michael B的方法。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接