sequence
От | Alain Roger |
---|---|
Тема | sequence |
Дата | |
Msg-id | 75645bbb0712090741h5c98b20jcb1c7a71017730d4@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: sequence
|
Список | pgsql-general |
Hi,
I'm still trying to understand how the sequences work under PostgreSQL.
for example i have a sequence called : users_user_id_seq
with :
current value = 1
min value = 1
max value = 9223372036854775807
start = 1
a typical "serial" field.
to perform an autoincrement in my SQL queries...specially while i use insert into i do the following thing :
INSERT INTO mytable VALUES
(
select nextval('users_user_id_seq'),
...
);
however this get the currentvalue + 1, or during creating the sequence i must say that start = 0.
how can i get the current value (to use it into my "insert into statement") and by the same time,. increment it by 1, to be ready for the next time ?
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
I'm still trying to understand how the sequences work under PostgreSQL.
for example i have a sequence called : users_user_id_seq
with :
current value = 1
min value = 1
max value = 9223372036854775807
start = 1
a typical "serial" field.
to perform an autoincrement in my SQL queries...specially while i use insert into i do the following thing :
INSERT INTO mytable VALUES
(
select nextval('users_user_id_seq'),
...
);
however this get the currentvalue + 1, or during creating the sequence i must say that start = 0.
how can i get the current value (to use it into my "insert into statement") and by the same time,. increment it by 1, to be ready for the next time ?
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
В списке pgsql-general по дате отправления: