Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group