Пример объединения строк

Вставьте или обновите строки в таблице COPY_EMP3 в соответствии с таблицей EMPLOYEES.

4-34-6835931

     MERGE INTO copy_emp3 c USING (SELECT * FROM EMPLOYEES ) e ON (c.employee_id = e.employee_id)

WHEN MATCHED THEN


UPDATE SET c.first_name = e.first_name, c.last_name = e.last_name, c.email = e.email, c.phone_number = e.phone_number, c.hire_date = e.hire_date, c.job_id = e.job_id, c.salary = e.salary*2, c.commission_pct = e.commission_pct, c.manager_id = e.manager_id, c.department_id = e.department_id

DELETE WHERE (E.COMMISSION_PCT IS NOT NULL)


WHEN NOT MATCHED THEN
INSERT VALUES(e.employee_id, e.first_name, e.last_name, e.email, e.phone_number, e.hire_date, e.job_id, e.salary, e.commission_pct, e.manager_id,

e.department_id);

Таблица COPY_EMP3 создается с помощью следующего кода:

     CREATE TABLE COPY_EMP3 AS SELECT * FROM EMPLOYEES
WHERE SALARY

Похожие записи