Example of PL/SQL INSERT Statement
Consider a table named employees with columns employee_id, first_name, last_name, and department:
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:
+-------------+------------+-----------+------------+
| employee_id | first_name | last_name | department |
+-------------+------------+-----------+------------+
| 101 | John | Doe | Sales |
+-------------+------------+-----------+------------+
Explanation: The output displays a single row representing an employee with an ID of 101, first name ‘John‘, last name ‘Doe‘, and department ‘Sales‘. Each column’s value aligns with the respective column headers: employee_id, first_name, last_name, and department.
PL/SQL INSERT Statement
The PL/SQL INSERT statement is vital for adding new records to a database table. By specifying the table’s name and providing values for its columns, users can populate their database with essential information. This functionality enables efficient data entry and ensures the completeness of datasets, facilitating various database operations and analyses.