Re: Sequence name with SERIAL type

From: Marek Lewczuk <newsy(at)lewczuk(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Lista dyskusyjna pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sequence name with SERIAL type
Date: 2003-12-17 10:15:52
Message-ID: 3FE02CD8.1080300@lewczuk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:

> Marek Lewczuk <newsy(at)lewczuk(dot)com> writes:
>
>>I'm curious if the default scheme for sequence name (which is created
>>with SERIAL data type) can be changed -- currently all sequences are
>>named like this: <table_name>_<field_name>_seq -- can it be changed for
>>e.g. <table_name>__<field_name>__seq ???
>
>
> Sure ... just hack one or two places in the sources ...
>
> That probably wasn't the answer you wanted, but I'm quite unsure what you did want.
I just asked is it can be done (somehow...).

> Are you suggesting the above would be a better default
> naming scheme? Are you saying you want user-configurability of implicit
> sequence names? In either case, what's your argument why we should
> invest effort and possibly create backwards-compatibility issues?

I'm not saying that proposed naming scheme is better - I think that it
is more readable, and I'm using it in my project.
Look at below examples:

Primary key:
1. <table_name>__pkey
(e.g. my_clients__pkey)

Foreign key:
1. <table_name>__<field>__fkey
(e.g. my_clients__client_id__fkey)
2. <table_name>__<field>_<field>__fkey
(e.g. my_clients__client_id_company_id__fkey)

Index:
1. <table_name>__<field>__index
(e.g. my_clients__country__index)
2. <table_name>__<field>_<field>_<field>__index
(e.g. my_clients__country_city_street__index)

Sequence:
1. <table_name>__<field>__seq
(e.g. my_clients__client_id__seq)

As you can see all naming schemes are very similar, and becouse of this
I just wanted to know if there is something like "user-configurability
implicit of sequence names". I didn't want to propose NEW naming scheme
- but maybe my naming schemes are worth looking at.

ML

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paul Ganainm 2003-12-17 11:02:32 Re: Firebird and PostgreSQL at the DB Corral.
Previous Message Marek Lewczuk 2003-12-17 09:58:06 Re: md5 function