PostgreSQL creates a self-growing field

Source: Internet
Author: User
Tags postgresql

Original: 77978316

The first step is to create the sequence: The generic sequence name consists of the data table name + primary key field +SEQ (typically the primary key field is the self-increment field), as the following table is named T_certificate, and the primary key is C_certificateid

Create the sequence statement as follows:

CREATE SEQUENCE T_certificate_c_certificateid_seq
START with 1
INCREMENT by 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

Step two, Set table field self-increment SQL

ALTER TABLE t_certificate ALTER COLUMN C_certificateid set default Nextval (' T_certificate_c_certificateid_seq ');

PostgreSQL creates a self-growing field

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.