Re: Last insert id

Поиск
Список
Период
Сортировка
От Rod Taylor
Тема Re: Last insert id
Дата
Msg-id 1087295408.27896.50.camel@jester
обсуждение исходный текст
Ответ на Re: Last insert id  ("Andrei Bintintan" <klodoma@ar-sd.net>)
Список pgsql-sql
On Tue, 2004-06-15 at 03:05, Andrei Bintintan wrote:
> "Is it safe to use "select max(table1_id) from table1" after the insert?"
> 
> Yes it is safe, but ONLY if you use it inside a transaction.(BEGIN/COMMIT).

No, this is not safe outside of the serializable isolation.

rbt=# begin;
BEGIN
rbt=# select max(id) from l;max
-----  1
(1 row)

rbt=# insert into l values (2);
INSERT 62597 1
rbt=# select max(id) from l;max
-----  3
(1 row)

rbt=# commit;
COMMIT

I inserted 3 from another connection after 2 was inserted.




В списке pgsql-sql по дате отправления:

Предыдущее
От: "Andrei Bintintan"
Дата:
Сообщение: Re: Last insert id
Следующее
От: "Jie Liang"
Дата:
Сообщение: Re: Prepare Statement