aboutsummaryrefslogtreecommitdiff
path: root/src/man/create_sequence.l
diff options
context:
space:
mode:
Diffstat (limited to 'src/man/create_sequence.l')
-rw-r--r--src/man/create_sequence.l19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/man/create_sequence.l b/src/man/create_sequence.l
index 0a695fa6bf4..588e70f3944 100644
--- a/src/man/create_sequence.l
+++ b/src/man/create_sequence.l
@@ -1,6 +1,6 @@
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/create_sequence.l,v 1.5 1998/07/14 01:45:25 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/create_sequence.l,v 1.6 1998/08/30 21:03:19 scrappy Exp $
.TH "CREATE SEQUENCE" SQL 07/13/98 PostgreSQL PostgreSQL
.SH NAME
create sequence - create a new sequence number generator
@@ -82,6 +82,14 @@ given sequence in the current backend session. Also beware that it
does not give the last number ever allocated, only the last one allocated
by this backend.
.PP
+The function
+.BR setval
+('sequence_name', value)
+may be used to set the current value of the specified sequence.
+The next call to
+.BR nextval
+will return the given value + the sequence increment.
+.PP
Use a query like
.nf
SELECT * FROM <sequence_name>;
@@ -134,6 +142,15 @@ select nextval ('seq');
-- Use sequence in insert
--
insert into table _table_ values (nextval ('seq'),...);
+.nf
+--
+-- Set the sequence value after a copy in
+--
+create function table_id_max() returns int4
+ as 'select max(id) from _table_'
+ language 'sql';
+copy _table_ from 'input_file';
+select setval('seq', table_id_max());
.fi
.SH "SEE ALSO"
drop_sequence(l).