Re: nextval, sequences and sequencenames - Mailing list pgsql-general

From wsheldah@lexmark.com
Subject Re: nextval, sequences and sequencenames
Date
Msg-id 200108201937.PAA02227@interlock2.lexmark.com
Whole thread Raw
In response to nextval, sequences and sequencenames  (Wieger Uffink <wieger@usmedia.nl>)
List pgsql-general

I think someone pointed out not long ago that that naming convention isn't
always 100% reliable.  How about creating the sequence dynamically (using that
naming convention even), then create the table dynamically and have it
explicitly use the sequence you just created.  That way you *know* the name of
the sequence; should probably check to be sure the name isn't already in use, or
trap for errors when creating the sequence and adjust accordingly.




Gordan Bobic <gordan%bobich.net@interlock.lexmark.com> on 08/15/2001 04:14:02 AM

To:   Wieger Uffink <wieger%usmedia.nl@interlock.lexmark.com>
cc:   PostgreSQL-General <pgsql-general%postgresql.org@interlock.lexmark.com>
      (bcc: Wesley Sheldahl/Lex/Lexmark)
Subject:  Re: [GENERAL] nextval, sequences and sequencenames


On Tue, 14 Aug 2001, Wieger Uffink wrote:

> My question:
> is there anyway of retreiving the sequence_name corresponding to the
> respective column,
> knowing just the tablename and columnname?
>
> The reason I need to do this, is because the application I write
> dynamicly creates new tables, and I have no way of knowing the sequence
> name before hand.
>

Try "tablename_fieldname_seq". That is the default sequence name for a
"serial" field.

Cheers.

Gordan


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html





pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: How do you recover a postgres db?
Next
From: Justin Clift
Date:
Subject: Re: Is it possible to work with big databases (up to 10Gb) under Postgres?