INSERT
Description
Inserts new rows into the specified table/view that will contain either the explicitly specified values or the values returned by the query expression.
Syntax
//Inserting one record
INSERT INTO [owner_name.] { table_name | view_name }
[ (column_name, column_name, ... ) ]
{ VALUES (value, value, ... )
//Inserting multiple records
INSERT INTO [owner_name.] { table_name | view_name }
[ (column_name, column_name, ... ) ]
{ VALUES (value1-1, value1-2, ... value1-n),
(value2-1, value2-3, ... value2-n),
...
};
//Inserting records from a query
INSERT INTO [owner_name.] { table_name | view_name }
[ (column_name, column_name, ... ) ]
query_expression ;
Notes
Parameters are not allowed in multiple value sets.
Examples
//Create table alerts
create table alerts
(
id integer not null identity (1,1)
, date_time timestamp
, alert_type character(20)
, description varchar(200)
, constraint alerts_constraint_pk primary key ( id )
);
//Inserting one record
INSERT INTO alerts
( date_time, alert_type, description )
VALUES
( '01/03/2022 15:16:10.000', 'NOTICE', 'Information' );
//Inserting records from a recordset
INSERT INTO alerts ( date_time, alert_type, description )
VALUES
( '02/04/2023 16:27:21.000', 'WARNING ', 'Minor alert' )
, ( '03/05/2024 17:38:32.000', 'CRITICAL', 'Major alert' )
, ( '04/06/2025 18:49:43.000', 'FAILURE ', 'P1' );
//Inserting records from a SELECT
INSERT INTO alerts ( date_time, alert_type, description )
SELECT date_time, alert_type, description FROM alerts ;
Authorization
The user executing this statement must have any of the following privileges:
If a query_expression is specified, then the user must have any of the following privileges:
SQL Compliance |
SQL-92, ODBC Core SQL grammar |
Environment |
Embedded SQL, interactive SQL, ODBC applications |
Related Statements |
Query Expressions |