Search code examples
sqlsql-updateoracle-sqldeveloperplsqldeveloperauto-generate

How to generate SQL update statements with IDE?


I have table in dev environment something like this

EMP_ID     NAME     DEPT
  1         A        AA
  2         B        BB
  3         C        CC

and I have same table in test environment but with null values in DEPT column. Is there anyway to generate update statements based on EMP_ID so that I can copy DEPT values from dev to test? For example IDE should generate : update EMPLOYEE set dept='AA' where EMP_ID=1. I use Oracle Sqldeveloper and PL/SQL Developer.


Solution

  • You can execute the below query to generate your update statements and copy the result which you can execute in your other environment.

    select 
        'update employee set dept = ''' || dept || ''' where emp_id = ' || emp_id || ';'
    from employee;