Press "Enter" to skip to content

Copying Rows from One Table to Another in Oracle Sql

Copying Rows from One Table to Another in Oracle Sql

Problem
You want to copy information from one table to another.
Solution
Use the INSERT statement with the SELECT option to copy data from one table to another. Suppose you
have a table of candidates applying for jobs at your company, with many of the same details as the
HR.EMPLOYEES table. This INSERT statement will insert into the HR.EMPLOYEES table based on a SELECT
statement on the CANDIDATES table.
insert into hr.employees
(employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, 􀂫
commission_pct, manager_id, department_id)
select 210, first_name, last_name, email, phone_number, sysdate, ‘IT_PROG’, 3500, 􀂫
NULL, 103, 60
from hr.candidates
where first_name = ‘Susan’
and last_name = ‘Jones’;