DB2 SQL DB GENERATED SEQUENCE : BASIC
Let say you add a column ID in your table and you want an incremented value for this column every time a new record is inserted in Table or later you want to re-sequence the same ID column starting from 1. There can be multiple tricks to achieve this but SQL provides multiple very simple and handy option to do all these tasks where a sequence of numbers need to generated.
- IDENTITY COLUMN
- SEQUENCE OBJECT
- GENERATE_UNIQUE function
In coming discussion we will talk about all these options in detail.