January 2002
Intermediate to advanced
640 pages
16h 39m
English
Construct a new table from the results of a SELECT.
SELECT [ ALL | DISTINCT [ ON ( distinct_expression [, ...] ) ] ] target_expression [ AS output_name ] [, ...] [ INTO [ TEMPORARY | TEMP ] [ TABLE ] new_table ] [ FROM from_item [ { , | CROSS JOIN } ...] ] [ WHERE condition ] [ GROUP BY aggregate_expression [, ...] ] [ HAVING aggregate_condition [, ...] ] [ { UNION | INTERSECT | EXCEPT [ALL] } select ] [ ORDER BY order_expression [ ASC | DESC | USING operator ] [, ...] ] [ FOR UPDATE [ OF update_table [, ...] ] ] [ LIMIT { ALL | count } [ { OFFSET | , } start ] ] from_item ::= { [ ONLY ] table_name [ * ] [ [ AS ] from_alias [ ( column_alias_list ) ] ] | ( select ) [ [ AS ] alias [ ( column_alias_list ) ] ] | from_item [ NATURAL ] join_type from_item [ ON ( join_condition ) | USING ( join_column_list ) ] } join_type ::= [ INNER | LEFT [ OUTER ] | RIGHT [ OUTER ] | FULL [ OUTER ] ] JOIN
Most SELECT INTO parameters are the same as for the SELECT command. The following two are the only parameters unique to SELECT INTO:
TEMPORARY, TEMPThe TEMPORARY (or TEMP) keyword indicates that
the table is for temporary use; it will be destroyed when the session has ended.
new_tableThe name of the new table created to hold the resulting rows of the query. This table will be created automatically and must not already exist before you execute this command.
Refer to the reference entry titled “CREATE TABLE” and the reference entry titled “SELECT” for a list of possible ...