| От | Dani Oderbolz |
|---|---|
| Тема | Re: can you select on an OID? |
| Дата | |
| Msg-id | 3EA63F3D.4020804@ecologic.de обсуждение исходный текст |
| Ответ на | can you select on an OID? ("Jay G. Scott" <gl@arlut.utexas.edu>) |
| Список | pgsql-novice |
Hi Jay,
>I want to insert a row; one of the items in the row is of
>type SERIAL. After I insert the row, I want to know what
>value was assigned to the SERIAL item, call it the f_id.
>
Whenever you create a SERIAL column, Postgresql creates an imlicit
Sequence in the background
(as SERIAL isn´t a real Datatype).
I am not entirely sure about the naming convention of this implicit
sequequence, I think it is like this:
TABBLENAME_COLUMNNAME_seq
So, you can get what you need using the currval function.
So if your table looks like this:
CREATE TABLE test
( first SERIAL );
then you can get the value like this:
SELECT currval('test_first_seq');
Regards, Dani
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера