Re: How to...

Поиск
Список
Период
Сортировка
От Joel Burton
Тема Re: How to...
Дата
Msg-id 3A31248C.3734.177F009@localhost
обсуждение исходный текст
Ответ на How to...  ("W. van den Akker" <wvdakker@wilsoft.nl>)
Список pgsql-sql
> Hi,
> 
> I'am wondering if it is possible to retrieve the last added
> record of a table?
> I don't think there is a default SQl-query to do so. Is there
> a PostgreSQL way?

What is it you want to do? If you want to find out what auto-
generated ID will be or was inserted, you can use a sequence 
function, like currval() on the sequence.

If you're just working in psql, you're shown the OID of insert as it 
happens. You could SELECT ... WHERE oid=xxxx to get the record 
back. Some interfaces (like DBD::Pg) provide functions to get this 
oid, so you could get the record that way.

If you don't mean the last insert period, but rather the last insert 
just to this table, you could add a TIMESTAMP column DEFAULT 
CURRENT_TIMESTAMP and just select the record w/the latest 
timestamp.

HTH,

--
Joel Burton, Director of Information Systems -*- jburton@scw.org
Support Center of Washington (www.scw.org)


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

Предыдущее
От: "W. van den Akker"
Дата:
Сообщение: How to...
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: trying to pattern match to a value contained in a column