SELECT INTO
Purpose
Using this command you can create a table, similar to CREATE TABLE AS. Refer to CREATE TABLE for more information.
Prerequisites
-
You need either the system privilege
USE ANY SCHEMAor the object privilegeUSAGEon the target schema, or the schema must be owned by you or one of your assigned roles. - You need the system privilege
CREATE ANY TABLE, orCREATE TABLEif the table is created in a schema owned by you or one of your assigned roles. - You need the appropriate
SELECTprivileges for all referenced objects.
Syntax
select_into::=
Usage Notes
- If columns are not directly referenced in the select list, but as compound expressions, then aliases must be specified for these columns.
- For detailed information about this syntax, refer to SELECT section.
Example
SELECT * INTO TABLE t2 FROM t1 ORDER BY 1;