Oracle:通过 SELECT 语句创建临时表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15569844/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:54:46  来源:igfitidea点击:

Oracle: create temporary table by a SELECT statement

oracle

提问by Revious

I've tried to mix a CREATE TABLE table_name AS SELECT .... statement with a GLOBAL temporary table statement. They don't mix very well.

我尝试将 CREATE TABLE table_name AS SELECT .... 语句与 GLOBAL 临时表语句混合使用。它们混合得不是很好。

Is my example wrong?

我的例子错了吗?

CREATE GLOBAL TEMPORARY TABLE a AS
(
   SELECT * from b
)
ON COMMIT PRESERVE ROWS;  

回答by DazzaL

it should be:

它应该是:

CREATE GLOBAL TEMPORARY TABLE a
ON COMMIT PRESERVE ROWS
AS
select * from b;

(add where 1=0 too if you didn't want to initially populate it for the current session with all the data from b).

(如果您不想用 b 中的所有数据最初为当前会话填充它,也添加 where 1=0 )。