Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle create table using with clause

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

like image 378
Rnet Avatar asked Mar 25 '11 06:03

Rnet


People also ask

Can we create a table with in Oracle?

In Oracle, CREATE TABLE statement is used to create a new table in the database. To create a table, you have to name that table and define its columns and datatype for each column. Syntax: CREATE TABLE table_name.

Which clause is used to create a table?

DEFAULT clause of CREATE TABLEUse the DEFAULT clause in the CREATE TABLE statement to specify the default value for the database server to insert into a column when no explicit value for the column is specified.

Can we use with clause in Oracle?

The WITH clause, or subquery factoring clause, is part of the SQL-99 standard and was added into the Oracle SQL syntax in Oracle 9.2. The WITH clause may be processed as an inline view or resolved as a temporary table.


1 Answers

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 
like image 89
a_horse_with_no_name Avatar answered Sep 21 '22 09:09

a_horse_with_no_name