Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

SELECT INTO

Focus mode
SELECT INTO - Amazon Redshift

Selects rows defined by any query and inserts them into a new table. You can specify whether to create a temporary or a persistent table.

Syntax

[ WITH with_subquery [, ...] ] SELECT [ TOP number ] [ ALL | DISTINCT ] * | expression [ AS output_name ] [, ...] [ EXCLUDE column_list ] INTO [ TEMPORARY | TEMP ] [ TABLE ] new_table [ FROM table_reference [, ...] ] [ WHERE condition ] [ GROUP BY expression [, ...] ] [ HAVING condition [, ...] ] [ { UNION | INTERSECT | { EXCEPT | MINUS } } [ ALL ] query ] [ ORDER BY expression [ ASC | DESC ] [ LIMIT { number | ALL } ] [ OFFSET start ]

For details about the parameters of this command, see SELECT.

Examples

Select all of the rows from the EVENT table and create a NEWEVENT table:

select * into newevent from event;

Select the result of an aggregate query into a temporary table called PROFITS:

select username, lastname, sum(pricepaid-commission) as profit into temp table profits from sales, users where sales.sellerid=users.userid group by 1, 2 order by 3 desc;

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.