Re: Re: nextval, sequences and sequencenames

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Wieger Uffink <wieger(at)usmedia(dot)nl>
Cc: Chris <csmith(at)squiz(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Re: nextval, sequences and sequencenames
Date: 2001-08-15 09:16:13
Message-ID: 20010815191613.A10244@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

On Wed, Aug 15, 2001 at 10:49:38AM +0200, Wieger Uffink wrote:
> Hi,
>
> First of all thanks for the reactions, but I think I have probably not
> made my problem clear enough.
>
> I know the sequence name will be some combination, usually as
> 'tablename_columnname_seq',
> when implicitly created during table creation.
> But when I create my table 'maincompetencies' with serial column
> 'maincompetencid'
> the sequence is named 'maincompetenc_maincompetenc_seq'. Clearly not the
> same as the above mentioned naming formula.

Yes, the max identifier length is 32.

> I have a hunch that table and column names are cut off after the first
> 13 characters, but im not sure if this is true, or will maybe change in
> future versions of postgre.

It's a tricky algorithm.

> What I would really like to do is just query Postgre, give the tablename
> and columnname in question, and retreive the exact sequencename. I know
> Postgre 'knows' this, it has that info stored somewhere, it just wont
> tell me :)

Well, it would be stored in the default value field of the column. You could
try to parse it out of there. I suggest however not using the serial
keyword, but instead building it yourself. Then you could call you sequence
maincompetencies_pseq or whatever you like.

Parsing it out of the system tables might not work in future versions
either. The only guarenteed way is to name them yourself.

HTH,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org>
http://svana.org/kleptog/
> It would be nice if someone came up with a certification system that
> actually separated those who can barely regurgitate what they crammed over
> the last few weeks from those who command secret ninja networking powers.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Widenius 2001-08-15 10:03:01 Re: [Fwd: MySQL Benchmark page - Problem with vacuum() in PostgreSQL]
Previous Message Wieger Uffink 2001-08-15 08:49:38 Re: Re: nextval, sequences and sequencenames

Browse pgsql-novice by date

  From Date Subject
Next Message Oliver Elphick 2001-08-15 11:51:10 Re: find and replace content
Previous Message Wieger Uffink 2001-08-15 08:49:38 Re: Re: nextval, sequences and sequencenames