第一種方法: table
create table testA
(
id serial primary key,
name character varying(128)
); test
serial 這種類型的變量每次就會本身增長1. 變量
第二種方法: 方法
create table testB im
( next
id integer primary key, top
name character varying(128) tab
); co
而後定義一個sequence來解決這個問題 block
create sequence toper_test_tid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
alter table test alter column id set default nextval('toper_test_tid_seq');