Oracle: creating a temporary table using a SELECT statement

I tried to mix the CREATE TABLE table_name AS SELECT .... statement with the GLOBAL outer table statement. They do not mix well.

Is my example wrong?

CREATE GLOBAL TEMPORARY TABLE a AS ( SELECT * from b ) ON COMMIT PRESERVE ROWS; 
+7
source share
1 answer

it should be:

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

(add where 1 = 0 too, if you do not want to fill it first for the current session with all the data from b).

+21
source

All Articles