Loading, please wait...

Sequences

How To Use Sequences In SQL

 

Introduction:
In this article, you will learn, what Sequences are and how to use Sequences in SQL.

 

SQL Sequence is a series of numerical. These sequences depend on a number of data in the tables because every row in a table holds a unique value and show data in the simplest way. These values are finding in an ascending or descending order at a fixed time.

 

Applications handle the relationship between sequences and tables. So the application shows a sequence to save its next value.

 

Syntax:

The basic syntax for creating a Sequence table is as follows:

create sequence Sequence_name

start with value1

increment by value1

cycle/ nocycle;

 

 

Example:

Step 1: Here, first we will create the table for Sequence.

 

Create sequence seq_1

start with 1

increment by 1

cycle;

 

 

 

Step 2: Then Insert data in this table.

 

INSERT into se value (1,'ayushi');

INSERT into se value (2,'shipra');

INSERT into se value (3,'vishu');

INSERT into se value (4,'avi');

 

 

 

Now select and execute the query.

 

Step 3: And the output is.

 

 

 

Summary:
Thus, we learned that sequence depends on a number of data, it is a series of numbers.