Update Example - SQL Update.

Community Help: DB2 Update - Code example of a SQL DB2 Update

Share your own experience     View front page

The following is a DB2 SQL update example. This is an example of how to update a timestamp column and set it equal to the current timestamp. The table is named "YOURTABLE", where it can have many columns, although we only update 1 in this example. You can update more then 1 of course.

Although this sample is a mainframe DB2 SQL example, it really doesn't matter where you are running as this is pretty much the same everywhere when using SQL. This will set the field named col_tms on all rows in the table equal to the current timestamp if the key_field has a 10 for its value. All other rows remain untouched.

Update YOURTABLE set col_tms = current timestamp where key_field = 10