pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Why the weak key is created as unique
3+ messages / 2 participants
[nested] [flat]

* Why the weak key is created as unique
@ 2001-10-04 15:08  Marat Khairullin <xmm@rambler.ru>
  0 siblings, 0 replies; 3+ messages in thread

From: Marat Khairullin @ 2001-10-04 15:08 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Why the weak key is created as unique
@ 2001-10-04 21:02  Marat Khairullin <xmm@rambler.ru>
  0 siblings, 1 reply; 3+ messages in thread

From: Marat Khairullin @ 2001-10-04 21:02 UTC (permalink / raw)
  To: pgsql-sql; +Cc: pgsql-general@postgresql.org

Example:

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] Why the weak key is created as unique
@ 2001-10-05 18:49  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Marat Khairullin <xmm@rambler.ru>
  0 siblings, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2001-10-05 18:49 UTC (permalink / raw)
  To: Marat Khairullin <xmm@rambler.ru>; +Cc: pgsql-sql; pgsql-general@postgresql.org


You probably do not want a serial in BBB since you want
to be setting the values.  Use "a int references AAA" instead
I think.





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-10-05 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-10-04 15:08 Why the weak key is created as unique Marat Khairullin <xmm@rambler.ru>
2001-10-04 21:02 Why the weak key is created as unique Marat Khairullin <xmm@rambler.ru>
2001-10-05 18:49 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

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