PostgreSQL increment primary keys

1, increment primary key; 2, create a sequence

First, using the SERIAL increment primary key

create table test_no(
    id SERIAL primary key,
    name varchar(20)
);

Second, create a sequence

CREATE SEQUENCE test_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;

application:

  test:

    

select nextval('test_seq');

 

Guess you like

Origin www.cnblogs.com/BillyYoung/p/11011522.html