pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marat Khairullin <xmm@rambler.ru>
To: pgsql-sql@postgresql.org
Subject: Why the weak key is created as unique
Date: Thu, 4 Oct 2001 18:08:29 +0300 (MSK)
Message-ID: <3BBC7B6D.AA21835@mb2.rambler.ru> (raw)

mydb=> create table AAA (a serial primary key);
NOTICE:  CREATE TABLE will create implicit sequence 'aaa_a_seq' for SERIAL column 'aaa.a'
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'aaa_pkey' for table 'aaa'
CREATE

mydb=> create table BBB (a serial references AAA, b integer, primary key(a,b));
NOTICE:  CREATE TABLE will create implicit sequence 'bbb_a_seq' for SERIAL column 'bbb.a'
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'bbb_pkey' for table 'bbb'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'bbb_a_key' for table 'bbb'
NOTICE:  CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
CREATE

mydb=> insert into AAA values (1);
INSERT 20369 1

mydb=> insert into BBB values (1,1);
INSERT 20370 1
mydb=> insert into BBB values (1,2);
ERROR:  Cannot insert a duplicate key into unique index bbb_a_key

I would like that the pair keys (a,b) was unique.
Certainly, I can remove unique index 'bbb_a_key'...
But how more correctly?
-- 
Marat Khairullin mailto:xmm@rambler.ru
Marat.Khairullin@f92.n5049.z2.fidonet.org
----
  Бесплатная почта http://mail.Rambler.ru/
  Рамблер-Покупки http://ad.rambler.ru/ban.clk?pg=1691&bn=9346



view thread (3+ messages)  latest in thread

Message-ID: <3BBC7B6D.AA21835@mb2.rambler.ru>
Permalink:  ../3BBC7B6D.AA21835@mb2.rambler.ru/
Also on:    postgresql.org/message-id/3BBC7B6D.AA21835@mb2.rambler.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: xmm@rambler.ru
  Subject: Re: Why the weak key is created as unique
  In-Reply-To: <3BBC7B6D.AA21835@mb2.rambler.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox