Oracle使用with子句创建表

时间:2021-03-31 09:13:16

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

我可以从使用with子句组成的查询中创建一个表吗?

2 个解决方案

#1


38  

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

#2


1  

The CREATE TABLE table_name AS statement creates a table based on a select statement. The solution for a with clause will be : CREATE TABLE t AS SELECT * FROM ( WITH some_data AS ( SELECT 1 as some_value FROM dual

CREATE TABLE table_name作为语句创建一个基于select语句的表。with子句的解决方案将是:创建表t作为SELECT * FROM(使用some_data作为FROM dual选择1作为some_value)

UNION ALL

UNION ALL

SELECT 2 FROM dual ) );

从dual中选择2);

#1


38  

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

#2


1  

The CREATE TABLE table_name AS statement creates a table based on a select statement. The solution for a with clause will be : CREATE TABLE t AS SELECT * FROM ( WITH some_data AS ( SELECT 1 as some_value FROM dual

CREATE TABLE table_name作为语句创建一个基于select语句的表。with子句的解决方案将是:创建表t作为SELECT * FROM(使用some_data作为FROM dual选择1作为some_value)

UNION ALL

UNION ALL

SELECT 2 FROM dual ) );

从dual中选择2);