ORACLE | ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
| ||||||||
|
Oracle - Insert
In Oracle, INSERT statement is used to add a single record or multiple records into the table.
INSERT INTO table
(column1, column2, ... column_n )
VALUES
(expression1, expression2, ... expression_n );
INSERT INTO table
(column1, column2, ... column_n )
SELECT expression1, expression2, ... expression_n
FROM source_table
WHERE conditions;
It is the simplest way to insert elements to a database by using VALUE keyword.
Consider here the already created suppliers table. Add a new row where the value of supplier_id is 23 and supplier_name is Flipkart.
INSERT INTO suppliers
(supplier_id, supplier_name)
VALUES
(50, 'Flipkart');
1 row(s) inserted.
0.02 seconds
This method is used for more complicated cases of insertion. In this method insertion is done by SELECT statement. This method is used to insert multiple elements.
In this method, we insert values to the "suppliers" table from "customers" table. Both tables are already created with their respective columns.
INSERT INTO suppliers
(supplier_id, supplier_name)
SELECT age, address
FROM customers
WHERE age > 20;
4 row(s) inserted.
0.00 seconds
You can even check the number of rows that you want to insert by following statement:
SELECT count(*)
FROM customers
WHERE age > 20;
Count(*)
4