0

I am brushing up my knowledge about SQL and I am learning more and more. However, I am not understanding the purpose of the Sequence we use. I am using SQL Server.

cbirole
  • 27
  • 2
  • 1
    A sequence is used to generate unique numbers efficiently (e.g. for generated primary keys) –  Jan 10 '22 at 08:15

1 Answers1

1

The sequence object is an alternative, more flexible key-generating mechanism than identity. Unlike identity, it’s not tied to a particular column in a particular table. Whenever you need to generate a new value, you invoke a function against the object and use the returned value wherever you like. It also supports specifying a minimum value and a maximum value, and cycling too.

Zakaria
  • 4,715
  • 2
  • 5
  • 31