Thread: Statistics from Sequences
- 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!
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
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.
[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
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 cleanlyThank you very much, you've been a great help.
Regards
Yahoo! Messenger com voz: PROMOÇÃO VOCÊ PODE LEVAR UMA VIAGEM NA CONVERSA. Participe!
[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