mirror of
https://github.com/postgres/postgres.git
synced 2026-02-15 16:48:17 -05:00
Add ALTER SEQUENCE to modify min/max/increment/cache/cycle values Also updated create sequence docs to mention NO MINVALUE, & NO MAXVALUE. New Files: doc/src/sgml/ref/alter_sequence.sgml src/test/regress/expected/sequence.out src/test/regress/sql/sequence.sql ALTER SEQUENCE is NOT transactional. It behaves similarly to setval(). It matches the proposed SQL200N spec, as well as Oracle in most ways -- Oracle lacks RESTART WITH for some strange reason. -- Rod Taylor <rbt@rbt.ca>
39 lines
849 B
PL/PgSQL
39 lines
849 B
PL/PgSQL
---
|
|
--- test creation of SERIAL column
|
|
---
|
|
|
|
CREATE TABLE serialTest (f1 text, f2 serial);
|
|
|
|
INSERT INTO serialTest VALUES ('foo');
|
|
INSERT INTO serialTest VALUES ('bar');
|
|
INSERT INTO serialTest VALUES ('force', 100);
|
|
INSERT INTO serialTest VALUES ('wrong', NULL);
|
|
|
|
SELECT * FROM serialTest;
|
|
|
|
CREATE SEQUENCE sequence_test;
|
|
|
|
BEGIN;
|
|
SELECT nextval('sequence_test');
|
|
DROP SEQUENCE sequence_test;
|
|
END;
|
|
|
|
-- renaming sequences
|
|
CREATE SEQUENCE foo_seq;
|
|
ALTER TABLE foo_seq RENAME TO foo_seq_new;
|
|
SELECT * FROM foo_seq_new;
|
|
DROP SEQUENCE foo_seq_new;
|
|
|
|
--
|
|
-- Alter sequence
|
|
--
|
|
CREATE SEQUENCE sequence_test2 START WITH 32;
|
|
|
|
SELECT nextval('sequence_test2');
|
|
|
|
ALTER SEQUENCE sequence_test2 RESTART WITH 16
|
|
INCREMENT BY 4 MAXVALUE 22 MINVALUE 5 CYCLE;
|
|
SELECT nextval('sequence_test2');
|
|
SELECT nextval('sequence_test2');
|
|
SELECT nextval('sequence_test2');
|
|
|