SELECT INTO

Description

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.

Click herearrow-up-right to navigate to the PostgreSQL documentation page for this syntax.

circle-info

The SELECT INTO is translated to CREATE OR REPLACE TABLE AS in snowflake.

Grammar Syntax

[ WITH [ RECURSIVE ] with_query [, ...] ]
SELECT [ALL | DISTINCT [ON ( expression [, ...] )]]
    * | expression [AS output_name] [, ...]
    INTO [TEMPORARY | TEMP | UNLOGGED ] [TABLE] new_table
    [FROM from_item [, ...]]
    [WHERE condition]
    [GROUP BY expression [, ...]]
    [HAVING condition [, ...]]
    [{UNION | INTERSECT | EXCEPT} [ALL | DISTINCT ] select]
    [ORDER BY expression [ASC | DESC | USING operator] [NULLS {FIRST | LAST}] [, ...]]
    [LIMIT {count | ALL}]
    [OFFSET start [ ROW | ROWS ] ]
    [FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]
    [FOR {UPDATE | SHARE} [OF table_name [, ...]] [NOWAIT] 
    [...]]

Sample Source Patterns

PostgreSQL

Snowflake

  1. MSC-PG0016arrow-up-right: The lock level is handled automatically in Snowflake.

  2. MSC-PG0017arrow-up-right: Select with Into clause is not compatible with snowflake, it is transformed to a Create Table As.

  3. MSC-PG0018arrow-up-right: Select with Into clause is not compatible with snowflake, it is transformed to a Create Table As And unlogged is not compatible with snowflake, all transactions are logged.

Last updated

Was this helpful?