Select Into
Nameselect INTO - Create a new table from the results of a query
Synopsis
SELECT [All | Distinct [ON (Expression [, ...])]]]]]]]]]
* | express [as output_name] [, ...]
INTO [Temporary | TEMP] [TABLE] New_TABLE
[From from_item [, ...]]]
[WHERE CONDITION]
[Group by express "[, ...]]
[Having condition [, ...]]]]
[{UNION | INTERSECT | Except} [all] select] SELECT]
[Order by Expression [ASC | DESC | Using Operator] [, ...]]
[For Update [of TableName "]]]]]
[Limited {count,] {count | all}]
[Offset Start]
Here
From_Item can be:
[ONLY] TABLE_NAME [*]
[[As] alias [(colorn_alias_list)]]]
|
(SELECT)
[As] alias [(colorn_alias_list)]
|
From_Item [Natural] join_type from_Item
[On join_condition | using (join_column_list)]
enter
Temporary
Temp
If this keyword is declared, the table is created as a temporary table. Please refer to CREATE TABLE to get details.
New_TABLE
The table name of the table to create (you can have outline modifications).
All other inputs are described in detail in Select.
Output
Please refer to CREATE TABLE and SELECT to get a summary of the possible output information.
description
Select Into creates a new table from a query calculation result. The Book Company does not return to the client, this point is different from ordinary select. The new table field has the name and data type associated with the output field of the Select.
Note: The role of CREATE TABLE AS is the same as Select Into. We recommend using the CREATE TABLE AS syntax because SELECT INTO is not a standard syntax. In fact, this type of SELECT INTO is not used in PL / PGSQL or ECPG because they are different from the interpretation of the INTO clause.
compatibility
SQL92 uses Select ... INTO to indicate the number of values to a sputum variable of a host program, not to create a new table. The use of SQL92 is actually used in PL / PGSQL and ECPG. PostgreSQL means that the creation of the creation table is historical reasons for the meaning of Select Into. In the new code, we'd better use Create Table AS to achieve this. (CREATE TABLE AS is not standard, but at least it has a little more confusing.)