delete from emp; Use the MERGE statement to select rows from one table for update or insertion into another table. those rows which are already present in sales_history, their amount should be updated and those rows which are not present in sales_history table should be inserted.The decision whether to update or insert into the target table is based on a condition in the ON clause. merge into sales_history sh using sales s on (s.prod=and s.month=sh.month) when matched then update set sh.amount=s.amount when not matched then insert values (prod,month,amount); After the statement is executed sales_history table will look like this.
Suppose we added the city column in the employee table and now we want to set this column with corresponding city column in department table which is join to employee table on deptno.We simply need to separate the columns in the SET clause with a comma. Assuming the country and area codes are unchanged and the phone id is 9, our insert statement would be as follows: Got that? Create an insert statement to put a new record (with an address_id of 4) into the ADDRESS table.Let me demonstrate: This method works just as well for three, four or however many columns; do bear in mind, however, that SQL will use the same WHERE clause to identify the record(s) to update. I don’t know how well you remember our database structure, but to record this information we will need to add the new number to the PHONE_NUMBER table (this will call for an INSERT statement), and then add a record (another INSERT) to the FRIEND_PHONE linking this new number with Rachel. You’ll want to remember that you’ll need to enclose VARCHAR2 strings in single quotes.update emp set city=(select city from dept where deptno= emp.deptno); Use the DELETE statement to delete the rows from existing tables which are in your schema or if you have DELETE privilege on them.For example to delete the employee whose empno is 102.