bjghzly 发表于 2016-11-22 00:54:45

Postgresql的主键自增长

  --建一个序列
create sequence id_seq increment 1 minvalue 1 maxvalue 9223372036854775807cache 1;--
  缓存是1,每次增加1
select setval('id_seq',1);--从1开始
--建表
create table buyers(
id int not null primary key default nextval('id_seq'),
name varchar(30)
)
页: [1]
查看完整版本: Postgresql的主键自增长