INSERT¶
Valid in: SQL, ESQL, DBProc, OpenAPI, ODBC, JDBC, .NET
The INSERT statement inserts rows into a table.
This statement has the following format:
- REPEATED
-
Saves the execution plan of the insert, which can make subsequent executions faster.
- column {,column}
-
Identifies the columns of the specified table into which the values are placed. When the column list is included, Actian Data Platform places the result of the first exprin the values list or subselect into the first column named, the second value into the second column named, and so on. The data types of the values must be compatible with the data types of the columns in which they are placed.
- OVERRIDING SYSTEM VALUE
-
Overrides the sequence value for a GENERATED ALWAYS AS IDENTITY column with the explicit value specified in the VALUES clause. Cannot be used on an INSERT...SELECT statement.
- OVERRIDING USER VALUE
-
Overrides the sequence value for a GENERATED BY DEFAULT IDENTITY column with the explicit value specified in the VALUES clause. Cannot be used on an INSERT...SELECT statement.
-
See CREATE TABLE.
- VALUES (expr{ ,expr}) {,(expr{ ,expr})} | subselect
-
Specifies the values to be inserted as one of the following:
- One or more comma-separated sets of lists of expressions, each representing one row of values for insertion. The expressions in each row must correspond with the column list specified.
- A subselect, which inserts all the rows that result from the evaluation of the subselect.
-
If a column corresponding to an expris the identity column and there is no OVERRIDING clause, the value must be DEFAULT.
- WITH common_table_expression
-
Defines a common table expression (see WITH (common_table_expression)).
INSERT Examples¶
When inserting values into a Actian Data Platform table, always insert many rows at a time rather than performing individual inserts. Consider using a staging table when single row inserts cannot be avoided.
INSERT INTO YYMD00 WITH emp_cte AS (SELECT emp.emp_rating, emp.emp_name, emp.employee_id FROM employee_dim emp WHERE emp_rating = 3) SELECT * FROM emp_cte;