Manipulate Data in Tables, Views, and Files
Insert Into a Table
Description
The INSERT INTO
statement inserts data into a table. The data comes from a subselect query. It is commonly used to input prediction results into a database table.
Syntax
Here is the syntax:
Please note that the destination table (integration_name.table_name
) must
exist and contain all the columns where the data is to be inserted.
And the steps followed by the syntax:
- It executes a subselect query to get the output dataset.
- It uses the
INSERT INTO
statement to insert the output of the(SELECT ...)
query into theintegration_name.table_name
table.
On execution, we get:
Example
We want to save the prediction results into the int1.tbl1
table.
Here is the schema structure used throughout this example:
Where:
Name | Description |
---|---|
int1 | Integration where the table that stores prediction results resides. |
tbl1 | Table that stores prediction results. |
predictor_name | Name of the model. |
int2 | Integration where the data source table used in the inner SELECT statement resides. |
tbl2 | Data source table used in the inner SELECT statement. |
Let’s execute the query.
On execution, we get: