SEQUENCES

Поиск
Список
Период
Сортировка
Искать

SEQUENCES

От:
"Rodrigo Sakai" <rodrigo.sakai@zanthus.com.br>
Дата:

  Hi all,

 

  I need to get all sequences and their respective current values! Is there any catalog table or any other away to get this???

 

  Thanks in advance.

Re: SEQUENCES

От:
Andrew Sullivan <ajs@crankycanuck.ca>
Дата:
On Mon, Oct 02, 2006 at 01:39:38PM -0300, Rodrigo Sakai wrote:
> 
>   I need to get all sequences and their respective current values! Is there
> any catalog table or any other away to get this???

Here's a quick way to do it in a shell script, although it'd be sort
of inefficient:

for name in `psql -c "select relname from pg_class where relkind =
'S'" dbname; do psql -c "select last_value from $name" dbname; done.

A


-- 
Andrew Sullivan  | ajs@crankycanuck.ca
Unfortunately reformatting the Internet is a little more painful 
than reformatting your hard drive when it gets out of whack.	--Scott Morris

Re: SEQUENCES

От:
Thomas Kellerer <spam_eater@gmx.net>
Дата:
Rodrigo Sakai wrote on 02.10.2006 18:39:
>   Hi all,
> 
>  
> 
>   I need to get all sequences and their respective current values! Is there
> any catalog table or any other away to get this???
> 
>  

Quote from the manual at:
http://www.postgresql.org/docs/8.1/static/catalog-pg-class.html

"The catalog pg_class catalogs tables and most everything else that has columns 
or is otherwise similar to a table. This includes indexes (but see also 
pg_index), sequences, views, composite types"

Thomas



Re: SEQUENCES

От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Mon, Oct 02, 2006 at 13:39:38 -0300, Rodrigo Sakai  wrote:
>   Hi all,
> 
>  
> 
>   I need to get all sequences and their respective current values! Is there
> any catalog table or any other away to get this???

You can get their names from pg_class (with relkind = 'S') and then iterate
over the names and look at the table underlying each table (at last_value).

FAQ