Sunday, May 17, 2020

Insert Statement

Insert Statement
INSERT statement is used to insert a single record or multiple records into a table in Oracle.
1.    To enter records into a table we use INSERT command
2.    Using "&" we can read the values from key board in SQL.
  •          INSERT statement when inserting a single record using the VALUES keyword is: 
Syntax:
INSERT INTO Table
(column1, column2, column3…. columnx)
VALUES
(Values1, values2, values3…...valuesx);

Example:













  •  INSERT statement when inserting multiple records using a SELECT statement is:
Syntax:
INSERT INTO Table
(column1, column2, column3…. columnx)
                        SELECT field1, field2, field3….. fieldx 
FROM source table
[WHERE condition] --- (where condition is optional)

Example:
INSERT INTO Employee
(emp_id, emp_name)
                        SELECT trainee_id, trainee_name 
FROM Trainee
WHERE status = 'A';

1 comment: