Greenplum管理序列
Greenplum管理序列
不支持currval和lastval,只有nextval,且不能在update和delete语句中使用。如果开启了mirroring,序列不能在update和delete语句中使用。
gtlions=# create sequence sq1 start 1;
CREATE SEQUENCE
gtlions=# select * from sq1;
sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
sq1 | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f
(1 row)
gtlions=# select nextval('sq1');
nextval
---------
1
(1 row)
gtlions=# insert into t1 values(nextval('sq1'),'a',19,date('2013-01-01'));
INSERT 0 1
gtlions=# insert into t1 values(nextval('sq1'),'a',19,date('2013-01-01'));
INSERT 0 1
gtlions=# alter sequence sq1 restart with 1;
ALTER SEQUENCE
gtlions=# select * from sq1;
sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
sq1 | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f
(1 row)
-EOF-