pangxia75 发表于 2016-11-20 08:51:08

Postgresql的主键自增长

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