Re: [SQL] database design SQL prob. - Mailing list pgsql-sql

From Don Yury
Subject Re: [SQL] database design SQL prob.
Date
Msg-id 379BE136.BF6EB662@vpcit.ru
Whole thread Raw
In response to Re: [SQL] database design SQL prob.  ("D'Arcy" "J.M." Cain <darcy@druid.net>)
Responses Re: [SQL] database design SQL prob.  ("D'Arcy" "J.M." Cain <darcy@druid.net>)
List pgsql-sql
"D'Arcy J.M. Cain" wrote:
> 
> 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.
> 

However, if you create table with primary key, for example 

create table tab(
id int4 primary key,
...
);

and make dump of database, it will write in dump file

create table tab(
id int4,
...
);
create unique index "tab_pkey" on "tab" using btree ("id");

So, after dump / restore difference between primary key and unique index
disappears.
Is it right?

Sincerely yours, Yury.
don.web-page.net, ICQ 11831432


pgsql-sql by date:

Previous
From: Martin Jackson
Date:
Subject: (no subject)
Next
From: "tjk@tksoft.com"
Date:
Subject: Re: [SQL] Expr Abbreviations/Functions?