- 创建sequence - CREATE SEQUENCE production_id_seq START 547 OWNED BY production.f_id;
- 修改sequence - ALTER SEQUENCE production_id_seq OWNED BY production.f_id;
- 设置字段所使用的sequence - 1 - dbname=# alter table production alter column f_id set default nextval('production_id_seq'::regclass); 
- 重置序列 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32- dbname=# \d production_id_seq 
 Sequence "public.production_id_seq"
 Column | Type | Value
 ---------------+---------+---------------------
 sequence_name | name | production_id_seq
 last_value | bigint | 748
 start_value | bigint | 1
 increment_by | bigint | 1
 max_value | bigint | 9223372036854775807
 min_value | bigint | 1
 cache_value | bigint | 1
 log_cnt | bigint | 0
 is_cycled | boolean | f
 is_called | boolean | t
 Owned by: public.production.f_id
 dbname=# alter sequence production_id_seq restart with 302;
 dbname=# \d production_id_seq
 Sequence "public.production_id_seq"
 Column | Type | Value
 ---------------+---------+---------------------
 sequence_name | name | production_id_seq
 last_value | bigint | 302
 start_value | bigint | 1
 increment_by | bigint | 1
 max_value | bigint | 9223372036854775807
 min_value | bigint | 1
 cache_value | bigint | 1
 log_cnt | bigint | 0
 is_cycled | boolean | f
 is_called | boolean | t
 Owned by: public.production.f_id
参考资料:
在Postgres里用Sequence