"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