Search notes:

SQL: INSERT statement

The purpose of the insert statement is to add data (that is: create new records) to a table.

Insert a single record into a table

INSERT INTO target_table                VALUES (1, 'one');
INSERT INTO target_table (col_1, col_2) VALUES (2, 'two');

Insert multiple records in one go

The individual records to be inserted can be separated with commas:
INSERT INTO target_table VALUES
('record'    , 'one'   ),
('another'   , 'record'),
 …;
Note, that this variant does not work with Oracle SQL (18c).

Insert the result of a query

The result of a select statement can be inserted into a table:
INSERT INTO target_table
  SELECT …
  FROM   …
;

INSERT OR IGNORE

create table tq84_t(id integer primary key, val text unique);

insert or ignore into tq84_t (val) values ('foo');
insert or ignore into tq84_t (val) values ('bar');
insert or ignore into tq84_t (val) values ('foo');
insert or ignore into tq84_t (val) values ('baz');

select * from tq84_t;
insert or ignore is equivalent to insert on conflict ignore.

See also

A trigger allows to specify a sequence of actions to be executed when one or more records are inserted into a table.
DML statements

Index