The NO CYCLE is the default if you don’t explicitly specify CYCLE or NO CYCLE. If you use NO CYCLE, when the limit is reached, attempting to get the next value will result in an error. The next number will be the minimum value for the ascending sequence and maximum value for the descending sequence. The CYCLE allows you to restart the value if the limit is reached. One value can be generated at a time.īy default, the sequence generates one value at a time i.e., no cache. The CACHE determines how many sequence numbers are preallocated and stored in memory for faster access. The default starting value is minvalue for ascending sequences and maxvalue for descending ones. The START clause specifies the starting value of the sequence. In case of a descending sequence, the default maximum value is -1 and the default minimum value is the minimum value of the data type of the sequence. If you use NO MINVALUEand NO MAXVALUE, the sequence will use the default value.įor an ascending sequence, the default maximum value is the maximum value of the data type of the sequence and the default minimum value is 1. ĭefine the minimum value and maximum value of the sequence. The increment specifies which value to be added to the current sequence value to create new value.Ī positive number will make an ascending sequence while a negative number will form a descending sequence. The data type of the sequence which determines the sequence’s minimum and maximum values. The default data type is BIGINT if you skip it. The valid data type is SMALLINT, INT, and BIGINT. The orders of numbers in the sequence are important. Summary: in this tutorial, you will learn about the PostgreSQL sequences and how to use a sequence object to generate a sequence of numbers.īy definition, a sequence is an ordered list of integers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |