pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Statistics from Sequences
6+ messages / 3 participants
[nested] [flat]

* Statistics from Sequences
@ 2005-09-07 02:43  Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>
  0 siblings, 2 replies; 6+ messages in thread

From: Joÿffffffffffe3o Carvalho @ 2005-09-07 02:43 UTC (permalink / raw)
  To: pgsql-sql

Is it possible to get from a sequence:

   The sequence owner
   The min value
   The max value
   The increment value
   The last used number

???

Regards

		
---------------------------------
 Yahoo! Messenger com voz: PROMOÇÃO VOCÊ PODE LEVAR UMA VIAGEM NA CONVERSA. Participe!

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Statistics from Sequences
@ 2005-09-07 03:26  Michael Fuhr <mike@fuhr.org>
  parent: Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>
  1 sibling, 2 replies; 6+ messages in thread

From: Michael Fuhr @ 2005-09-07 03:26 UTC (permalink / raw)
  To: Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>; +Cc: pgsql-sql

On Tue, Sep 06, 2005 at 11:43:44PM -0300, Joÿffffffffffe3o Carvalho wrote:
> Is it possible to get from a sequence:
> 
>    The sequence owner
>    The min value
>    The max value
>    The increment value
>    The last used number

See the output from the following example:

CREATE SEQUENCE fooseq;

SELECT u.usename
FROM pg_class AS c JOIN pg_user AS u ON u.usesysid = c.relowner
WHERE c.relname = 'fooseq';

SELECT * FROM fooseq;

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Statistics from Sequences
@ 2005-09-07 03:38  Bruno Wolff III <bruno@wolff.to>
  parent: Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>
  1 sibling, 0 replies; 6+ messages in thread

From: Bruno Wolff III @ 2005-09-07 03:38 UTC (permalink / raw)
  To: Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>; +Cc: pgsql-sql

On Tue, Sep 06, 2005 at 23:43:44 -0300,
  Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br> wrote:
> Is it possible to get from a sequence:
> 
>    The sequence owner
>    The min value
>    The max value
>    The increment value
>    The last used number

Yes. Associated with each sequence is a one row table with the name of the
sequence. Note that numbers can be allocated and not used, so the last_value
may not be exactly what you want.

To get the owner you can combine pg_class with pg_user to get the table
owner. I didn't see this information in the information schema.



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Statistics from Sequences
@ 2005-09-08 20:08  Michael Fuhr <mike@fuhr.org>
  parent: Michael Fuhr <mike@fuhr.org>
  1 sibling, 1 reply; 6+ messages in thread

From: Michael Fuhr @ 2005-09-08 20:08 UTC (permalink / raw)
  To: Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>; +Cc: pgsql-sql

[Please copy the mailing list on replies so others can participate
in and learn from the discussion.]

On Thu, Sep 08, 2005 at 02:32:12PM -0300, Joÿffffffffffe3o Carvalho wrote:
> Can you give me a help about:
> 
> >    The min value
> >    The max value
> >    The increment value
> >    The last used number

The example I posted shows how to obtain those values:

CREATE SEQUENCE fooseq;
SELECT * FROM fooseq;

If you want only particular columns then specify them:

SELECT min_value, max_value, increment_by, last_value FROM fooseq;

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Statistics from Sequences
@ 2005-09-08 20:53  Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>
  parent: Michael Fuhr <mike@fuhr.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Joÿffffffffffe3o Carvalho @ 2005-09-08 20:53 UTC (permalink / raw)
  To: pgsql-sql



Michael Fuhr <mike@fuhr.org> escreveu:
[Please copy the mailing list on replies so others can participate
in and learn from the discussion.]

On Thu, Sep 08, 2005 at 02:32:12PM -0300, Joÿffffffffffe3o Carvalho wrote:
> Can you give me a help about:
> 
> > The min value
> > The max value
> > The increment value
> > The last used number

The example I posted shows how to obtain those values:

CREATE SEQUENCE fooseq;
SELECT * FROM fooseq;

If you want only particular columns then specify them:

SELECT min_value, max_value, increment_by, last_value FROM fooseq;

-- 
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly


Thank you very much, you've been a great help.

Regards


		
---------------------------------
 Yahoo! Messenger com voz: PROMOÇÃO VOCÊ PODE LEVAR UMA VIAGEM NA CONVERSA. Participe!

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Statistics from Sequences
@ 2005-09-08 22:04  Michael Fuhr <mike@fuhr.org>
  parent: Michael Fuhr <mike@fuhr.org>
  1 sibling, 0 replies; 6+ messages in thread

From: Michael Fuhr @ 2005-09-08 22:04 UTC (permalink / raw)
  To: Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>; +Cc: pgsql-sql

[Again, please copy the mailing list on replies so others can
participate in and learn from the discussion.]

On Thu, Sep 08, 2005 at 06:25:33PM -0300, Joÿffffffffffe3o Carvalho wrote:
> There's one thing. If the sequence name was fooseq in uppercase
> (FOOSEQ) it does not work. In that case it returns the error: ERROR:
> relation "fooseq" does not exist.

This isn't a sequence issue, it's an identifier issue.  See "Why
are my table and column names not recognized in my query?" in the
FAQ and "Identifiers and Key Words" in the documentation:

http://www.postgresql.org/docs/faqs.FAQ.html#4.20
http://www.postgresql.org/docs/8.0/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2005-09-08 22:04 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-07 02:43 Statistics from Sequences Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>
2005-09-07 03:26 ` Michael Fuhr <mike@fuhr.org>
2005-09-08 20:08   ` Michael Fuhr <mike@fuhr.org>
2005-09-08 20:53     ` Joÿffffffffffe3o Carvalho <joaocarvalho127@yahoo.com.br>
2005-09-08 22:04   ` Michael Fuhr <mike@fuhr.org>
2005-09-07 03:38 ` Bruno Wolff III <bruno@wolff.to>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox