Oracle create table using with clause

Rnet picture Rnet · Mar 25, 2011 · Viewed 54.7k times · Source

Can I create a table from a query formed using with clause?

Answer

a_horse_with_no_name picture a_horse_with_no_name · Mar 25, 2011

Sure:

CREATE TABLE t
AS 
WITH some_data AS ( 
   SELECT 1 as some_value 
   FROM dual

   UNION ALL 

   SELECT 2 
   FROM dual
) 
SELECT * 
FROM some_data