Re: oid's and primary keys on insert

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: oid's and primary keys on insert
Дата
Msg-id 20020809180454.Q7239@mail.libertyrms.com
обсуждение исходный текст
Ответ на Re: oid's and primary keys on insert  (Rob Brown-Bayliss <rob@zoism.org>)
Ответы Re: oid's and primary keys on insert  (Rob Brown-Bayliss <rob@zoism.org>)
Список pgsql-general
On Sat, Aug 10, 2002 at 09:13:46AM +1200, Rob Brown-Bayliss wrote:
> So if all goes well, each morning each site will start with essentially
> identical databases.  Many tables in the database refer to transactions
> specific to one site or another.  The primary key on these tables are
> inserted via a trigger, and are in the form of "location-sequence" so
> that this  46-23456 represents the primary key for location 46, sequence
> 23456 on that machine.

Why don't you use a sequence at each site and a "site id" field?
Then put a unique index on the site id + the sequence.  You'd get
something like

    |site_id|trans_id|
    ------------------
    |  46   | 23456  |

Also makes it easier to get "all transactions from site 46".  You can
even set each site's site_id field to the appropriate default, if you
want, so that you don't have to handle it in your code.

> Doesnt' PostgreSQL use the OID's for it's own internal use?  So that
> every item has a unique identifier for postgresql to play with, not
> necessarily the user)

No, every item doesn't need it.  System things do.  So tables are
identified by OID.  But a field in a table is field n of table OIDnn.

A

--
----
Andrew Sullivan                               87 Mowat Avenue
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M6K 3E3
                                         +1 416 646 3304 x110


В списке pgsql-general по дате отправления:

Предыдущее
От: "Nigel J. Andrews"
Дата:
Сообщение: Re: oid's and primary keys on insert
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: oid's and primary keys on insert