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-- ---------------------------------------------------------------
1
2//to insert value
3INSERT INTO students VALUES (200, 'Jones', 101);
4INSERT INTO students VALUES (201, 'Smith', 101);
5INSERT INTO students VALUE (202, 'Lee' , 102);
1It is possible to write the INSERT INTO statement in two ways:
2
31. Specify both the column names and the values to be inserted:
4INSERT INTO table_name (column1, column2, column3, ...)
5VALUES (value1, value2, value3, ...);
6
72. If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. Here, the INSERT INTO syntax would be as follows:
8INSERT INTO table_name
9VALUES (value1, value2, value3, ...);
1INSERT INTO users (first_name, last_name, address, email)
2VALUES (‘Tester’, ‘Jester’, ‘123 Fake Street, Sheffield, United
3Kingdom’, ‘test@lukeharrison.dev’);