Geneate Insert/Update/Delete

From SQLBWiki

Jump to: navigation, search

It is possible to generate a file containing either insert, update or delete statements for each record of a table. You can narrow down the set of records for which to generate the statements by specifying a restrictive where clause. For example, given the table:

 create table t (
   c1 int primary key,
   c2 int
 )

with content:

 c1 c2
  1 11
  2 12
  3 13

If we specify c1>1 in the where clause field, it will only generate updates for rows 2 & 3:

  /*
  Generated with SQLBrowser on 20 08 2009
  Where Clause: where c1>1
  */
  update propagation..t
  set c2 = 12
  where c1 = 2

  update propagation..t
  set c2 = 13
  where c1 = 3

The update and delete need to know the PK of the table in order to generate the where clause

Personal tools