Re: determine sequence name for a serial

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: determine sequence name for a serial
Date: 2004-10-28 23:55:51
Message-ID: 87u0seqtx4.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"Ed L." <pgsql(at)bluepolka(dot)net> writes:

> In PostgreSQL, at least for the past 5 years if not longer, if you create a
> SERIAL column for (schemaname, tablename, columnname), then your sequence
> will *always* be "schemaname.tablename_columnname_seq". If that naming
> convention changes, there will be a whole lotta breakage world-wide.

I hope you're wrong about people expecting that to be true because it isn't.
The resulting sequence name is limited to 63 characters and gets truncated if
it goes over. (63!? was it intended to be 64?) I believe the limit used to be
32 characters too.

In any case it's just plain good design to avoid unnecessary
interrelationships between different parts of the code. Practically speaking
it makes renaming something not involve an error-prone search and replace.
More importantly it makes it easier to verify that a piece of code is correct
without having to hunt down all the related bits to be sure the relationships
are correct. It also makes it possible to reuse or refactor the code.

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jerry LeVan 2004-10-29 00:22:12 Upgrading from beta3 to beta4
Previous Message Ed L. 2004-10-28 23:50:35 Re: determine sequence name for a serial