- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use and syntax of SEQUENCE in DB2?
A sequence is used to generate the unique ID automatically. We can define a column in the DB2 table as type SEQUENCE. This will enable DB2 to automatically generate a unique ID for every new row inserted in the table. The auto ID generated by the DB2 remains unique throughout the database.
For example, the practical implementation of SEQUENCE comes in case there are separate ORDERS tables assigned for each region North, East, West and South, then we can declare ORDER_ID as SEQUENCE. This will always generate a unique value for ORDER_ID irrespective of the ORDER table assigned for North, East, West and South.
The above SEQUENCE can be defined as follows.
Example
CREATE SEQUENCE ORDER_SEQ AS INTEGER START WITH 1 INCREMENT BY 1 NOMAXVALUE;
- Related Articles
- Usage and syntax of INNER and OUTER JOIN in DB2
- Purpose and usage of ROW-ID and SEQUENCE in a DB2
- How to use SQLCA in a COBOL-DB2 program? What is the purpose of SQLCA?
- What is the use of the VALUE function in a DB2? Explain with the help of an example
- Write the syntax to declare a scrollable cursor on the ORDERS DB2 table.
- What is a scriptlet in JSP and what is its syntax?
- What is Syntax Tree?
- What is syntax of tuple declaration in Python?
- What is the definition and usage of alternate key in a DB2 table?
- How will you create a new TRIGGER on the ORDERS DB2 table? Give the syntax of TRIGGER
- What is Implementation of Syntax Directed Translators?
- What is the difference between Parse Tree and the Syntax Tree?
- What is the Syntax Directed Translation?\n
- What is the significance of ACCESSTYPE and INDEXONLY column of a PLAN table in DB2?
- What is the syntax for boolean values in MongoDB?

Advertisements