1--sql insert quest example
2INSERT INTO table_name (column1, column2, column3, ...)
3VALUES (value1, value2, value3, ...);
1-- Note: This is specifically for SQL - Oracle
2-- ---------------------------------------------------------------
3-- OPTION 1: Insert specific values (other values will be null)
4
5-- syntax
6INSERT INTO <TABLE_NAME> (<column1>,<column2>,<column3>,...)
7VALUES (<value1>,<value2>,<value3>,...);
8
9-- example
10INSERT INTO SALES (SALE_ID,ITEM_ID,QUANTITY,AMOUNT)
11VALUES (631,13,4,59.99);
12-- ---------------------------------------------------------------
13-- OPTION 2: Insert a value for every field
14
15-- syntax
16INSERT INTO <TABLE_NAME> VALUES (<value1>,<value2>,...,<valueN>);
17
18-- example (SALES table only consists of 4 columns)
19INSERT INTO SALES VALUES (631,13,4,59.99);
20-- ---------------------------------------------------------------
1INSERT INTO table_name (a, b) VALUES (val1, val2);
2INSERT INTO table_name (a, b) VALUES (val1, val2), (val3, val4); -- 2 rows
3
4-- From a query:
5INSERT INTO table_name (a, b)
6 SELECT val1 AS a, val2 AS b
7 FROM source_table s
8 WHERE s.val1 >= 10;
1INSERT INTO client (prenom, nom, ville, age)
2 VALUES
3 ('Rébecca', 'Armand', 'Saint-Didier-des-Bois', 24),
4 ('Aimée', 'Hebert', 'Marigny-le-Châtel', 36),
5 ('Marielle', 'Ribeiro', 'Maillères', 27),
6 ('Hilaire', 'Savary', 'Conie-Molitard', 58);
1/*No List parameters */
2INSERT INTO table_name
3
4VALUES (value1, value2, value3, ...);
1
2INSERT INTO Customers (CustomerName, City, Country)
3
4VALUES ('Cardinal', 'Stavanger', 'Norway');
5