INSERT
Insert records into a table, either from values provided in the SQL command or from rows returned by a SELECT statement.
If the table does not exist or the schema does not match, the INSERT operation fails.
INSERT INTO <table_name>
[ ( <column_name1> [, <column_name2> ...]) ]
{ <select_statement>
| VALUES (value [, value ...]) [, (value [, value ...]) ...] }
Parameters
<table_name> String
The name of the table that you want to insert data into.
( <column_name1> [, <column_name2> ...] ) String Optional
The name of the column or columns that you want to insert data into.
- If column names are specified, data is inserted in the given column order, and columns not listed are populated as
NULL. - If column names are not specified, data is inserted in the column order of the table.
- Make sure the columns adhere to
NOT NULLconstraints specified in the table definition, or else theINSERTcommand fails with an error message.
<select_statement> String Optional
The query that you want to use to insert into the current table data from another table.
VALUES (value [, value ...]) [, (value [, value ...]) ...] String Optional
The value or values that you want to insert, if you specified the names of one or more columns. You can insert one or more sets of values, each set corresponding to a record to insert into the table.
Examples
Inserts three recordsINSERT INTO myTable VALUES
(21, 'Ruth Asawa', 'American, 1926–2013', 'American', 'Female', 1926, 2013, 'Q7382874', '500077806'),
(38, 'Magdalena Abakanowicz', 'Polish, 1930–2017', 'Polish', 'Female', 1930, 2017, 'Q158080', '500084577'),
(56, 'Luis Alberto Acuña', 'Colombian, 1904–1994', 'Colombian', 'Male', 1904, 1994, null, null)
INSERT INTO myTable
VALUES
(21, 'Ruth Asawa', 'American, 1926–2013', 'American', 'Female', 1926, 2013, 'Q7382874', '500077806'),
(38, 'Magdalena Abakanowicz', 'Polish, 1930–2017', 'Polish', 'Female', 1930, 2017, 'Q158080', '500084577'),
(56, 'Luis Alberto Acuña', 'Colombian, 1904–1994', 'Colombian', 'Male', 1904, 1994, null, null)
INSERT INTO struct_type VALUES (convert_from('{ x: "hi" }', 'json'))