I have two tables almost identical:
employeeemployee_history
The second table has two additional fields.
I would like to copy a record from employee into employee_history using an INSERT with a subquery. Sort of like this:
INSERT INTO employee_history SELECT * FROM employee WHERE id = idQ
My problem is that I need to add information into the 2 fields employee_history has that employee does not have:
update_codedate_of_change.
Is there a way I can copy a record from employee into employee_history keeping it simple like with the above insert statement while adding the 2 new pieces of data?
Alias the
employeetable and select all the columns then add the two new columns wherever they fit (at the beginning or end of the list):You need to alias the table because you would get an error (
ORA-00923: FROM keyword not found where expected) if you ran it as such:The problem would be if your two additional columns in the
employee_historytable were in the middle of the list of columns in theemployeetable. In that case you’d have to individually select each column.