|
Home > Archive > Slony1 PostgreSQL Replication > February 2006 > what constitutes a suitable 'primary key'?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
what constitutes a suitable 'primary key'?
|
|
| Marc G. Fournier 2006-02-12, 1:23 pm |
|
Apparently a UNIQUE index doesn't?
=# \d bit1
Table "public.bit1"
Column | Type | Modifiers
---------------+-----------------------------+---------------
instance_id | integer | not null
instance_name | character varying(500) | not null
created_on | timestamp without time zone | default now()
code | text |
md5sum | text |
status | text |
activated_on | text |
esdnet_uuid | text |
license | text |
account_uuid | text |
Indexes:
" bit1_instance_id_key
" UNIQUE, btree (instance_id)
"bit1lin_idx" btree (lower(instance_name
::text))
Gets reported by slony has having no primary key:
ERROR: Slony-I: table "public"."bit1" has no primary key
So, just to clarify before I do it, all tables that have 'just a UNIQUE
key', I'll still have to do 'ALTER TABLE <table> ADD PRIMARY KEY ( field
);' to so that Slony likes them?
| |
| Christopher Browne 2006-02-12, 8:24 pm |
| "Marc G. Fournier" <marc-b5wryfK2E/4AvxtiuMwx3w@public.gmane.org> writes:
> Apparently a UNIQUE index doesn't?
>
> =# \d bit1
> Table "public.bit1"
> Column | Type | Modifiers
> ---------------+-----------------------------+---------------
> instance_id | integer | not null
> instance_name | character varying(500) | not null
> created_on | timestamp without time zone | default now()
> code | text |
> md5sum | text |
> status | text |
> activated_on | text |
> esdnet_uuid | text |
> license | text |
> account_uuid | text |
> Indexes:
> " bit1_instance_id_key
" UNIQUE, btree (instance_id)
> "bit1lin_idx" btree (lower(instance_name
::text))
>
> Gets reported by slony has having no primary key:
>
> ERROR: Slony-I: table "public"."bit1" has no primary key
>
> So, just to clarify before I do it, all tables that have 'just a UNIQUE
> key', I'll still have to do 'ALTER TABLE <table> ADD PRIMARY KEY ( field
> );' to so that Slony likes them?
In the Slonik "set add table" command, you can specify which key to
use if there is no true primary key.
--
(reverse (concatenate 'string "ofni.sailifa.ac" "@" "enworbbc"))
<http://dba2.int.libertyrms.com/>
Christopher Browne
(416) 673-4124 (land)
| |
| Vivek Khera 2006-02-13, 1:24 pm |
|
On Feb 12, 2006, at 2:06 PM, Marc G. Fournier wrote:
> So, just to clarify before I do it, all tables that have 'just a
> UNIQUE
> key', I'll still have to do 'ALTER TABLE <table> ADD PRIMARY KEY
> ( field
> );' to so that Slony likes them?
As long as it is unique + NOT NULL column, it is equivalent to a PK.
Just tell slony which index qualifies for this. it will not
automatically figure it out.
|
|
|
|
|