![]() |
VOOZH | about |
The PL/SQL INSERT statement is used to add new records into a database table, ensuring that data is stored in a structured and complete manner. It helps in tasks such as:
Syntax:
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);Example: Create a table named employees with columns employee_id, first_name, last_name, and department
Query:
CREATE TABLE employees (
employee_id INT,
first_name VARCHAR(50),
last_name VARCHAR(50),
department VARCHAR(50)
);
INSERT INTO employees (employee_id, first_name, last_name, department)
VALUES (101, 'John', 'Doe', 'Sales');Output:
👁 Screenshot-2026-02-04-113713The PL/SQL INSERT statement can also act based on the SELECT query, which is used to select data from another table.
Example: Assume we have another table of name New_employees with the same columns as the employees table. We would like to load data in the New_employees table from the employees table.
Query:
INSERT INTO employees (employee_id, first_name, last_name, department)
VALUES
(102, 'Alice', 'Smith', 'Marketing'),
(103, 'Bob', 'Johnson', 'Finance'),
(104, 'Emily', 'Brown', 'HR');
CREATE TABLE New_employees (
employee_id INT,
first_name VARCHAR(50),
last_name VARCHAR(50),
department VARCHAR(50)
);
INSERT INTO New_employees
SELECT * FROM employees
WHERE 1 != 2;
Output:
👁 Screenshot-2026-02-04-115208