select t.*
into #temp
from
(
select 'a' as a
union all
select 'b' as a
) as t
select * from #temp
drop table #temp
我通常在SQL服务器上执行此操作,其中我创建了一个临时表。 语法"into #temp"将在数据库上创建一个非物理表,而"into temp"将在数据库上创建一个物理表。
我在MySQL中的问题是转换上面的MSSQL语句。我想要创建的是一个不是在数据库上物理创建的临时表。我们在 MySQL 中有这个功能吗?
在MySQL中,您将使用create temporary table as
:
create temporary table temp as
select 'a' as a
union all
select 'b' as a ;