


Defines a new table from the results of a query.


[ WITH [ RECURSIVE1 ] with_query [, ...] ]
    INTO [TEMPORARY | TEMP] [TABLE] new_table
    [FROM from_item [, ...]]
    [WHERE condition]
    [GROUP BY expression [, ...]]
    [HAVING condition [, ...]]
    [LIMIT {count | ALL}]
    [OFFSET start]


Note: 1The RECURSIVE keyword is an experimental feature and is not recommended for production use.

SELECT INTO creates a new table and fills it with data computed by a query. The data is not returned to the client, as it is with a normal SELECT. The new table's columns have the names and data types associated with the output columns of the SELECT.

The RECURSIVE keyword can be enabled by setting the server configuration parameter gp_recursive_cte_prototype to true.
Warning: The RECURSIVE keyword is an experimental feature and is not intended for use in a production environment. Experimental features are subject to change without notice in future releases.


The majority of parameters for SELECT INTO are the same as SELECT.

If specified, the table is created as a temporary table.



SELECT * INTO films_recent FROM films WHERE date_prod >= 


The SQL standard uses SELECT INTO to represent selecting values into scalar variables of a host program, rather than creating a new table. The Greenplum Database usage of SELECT INTO to represent table creation is historical. It is best to use CREATE TABLE AS for this purpose in new applications.