From: | "D'Arcy" "J(dot)M(dot)" Cain <darcy(at)druid(dot)net> |
---|---|
To: | stuart(at)ludwig(dot)ucl(dot)ac(dot)uk (Stuart Rison) |
Cc: | Frederic(dot)De(dot)Leersnijder(at)pandora(dot)be, pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] database design SQL prob. |
Date: | 1999-07-24 11:49:38 |
Message-ID: | m1180J8-0000bFC@druid.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
Thus spake Stuart Rison
> Currently, in postgreSQL, primary keys are created as a UNIQUE index on the
> field(s) that form the primary key.
>
> This means that there is no difference between explicitely declaring a
> PRIMARY KEY in your table definition or using the CREATE UNIQUE INDEX
> command.
Not completely accurate. Create some tables using both methods then
run the following query.
SELECT pg_class.relname, pg_attribute.attname
FROM pg_class, pg_attribute, pg_index
WHERE pg_class.oid = pg_attribute.attrelid AND
pg_class.oid = pg_index.indrelid AND
pg_index.indkey[0] = pg_attribute.attnum AND
pg_index.indisprimary = 't';
This will give you a list of the primary keys if you declare them as
primary at creation time. The ones created with just a unique index
won't be displayed.
While I am on the subject, anyone know how to enhance the above query
to display all the fields when a complex primary key is defined? The
above assumes that all primary keys are one field per table.
--
D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
From | Date | Subject | |
---|---|---|---|
Next Message | D'Arcy J.M. Cain | 1999-07-24 12:00:12 | Re: [HACKERS] Phantom row from aggregate in self-join in 6.5 |
Previous Message | Oleg Bartunov | 1999-07-24 10:41:59 | Re: inserts/updates problem under stressing ! |
From | Date | Subject | |
---|---|---|---|
Next Message | Kenneth Jacker | 1999-07-24 15:13:19 | Expr Abbreviations/Functions? |
Previous Message | Oleg Bartunov | 1999-07-24 09:48:29 | inserts/updates problem under stressing ! |