title: How to generate the primary key in DB2 (SQL Optimization)
body: <p>I use the following statement to generate my primary key. table2 keeps the curent primary key.  But it is too slow. How can i optimize this proces.</p>
  
  <pre><code>update table1 t set ID =ROW_NUMBER() OVER ();
  
  update table1 t 
  set ID = (Select NUMGEN.currentvalue + ID from  table1 data, table2 NUMGEN 
  where NUMGEN.tablename = 'table1' and t.Id = data.ID  );
  </code></pre>