Postgresql self-increment statement

Source: Internet
Author: User
Tags postgresql

If you simply start with 1, and the value of the increment is 1, you can write this, Serail is a special type:


Add values and their results to the employee:


If you want to set more detailed items, such as Start, increment, maximum, minimum, you can define a sequence.

In sequence, if no minvalue, no maxvalue indicates a minimum maximum value of-1, note that the minimum value cannot be greater than the maximum value.


Then change the columns of the table:


Add values and their results to the employee:


Decrement to change the increment by property value to a negative number:


Add values and their results to the employee:


The minimum value is reached and no further input is allowed.

The data in this table:


Postgresql self-increment statement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.