Received: from vpcit.ru (qmailr@dialup.vpcit.ru [195.38.52.246]) by hub.org (8.9.3/8.9.3) with SMTP id AAA48418 for ; Mon, 26 Jul 1999 00:16:28 -0400 (EDT) (envelope-from yura@vpcit.ru) Received: (qmail 32085 invoked from network); 26 Jul 1999 04:16:23 -0000 Received: from gercon.vpcit.ru (HELO vpcit.ru) (195.38.52.226) by dialup.vpcit.ru with SMTP; 26 Jul 1999 04:16:23 -0000 Message-ID: <379BE136.BF6EB662@vpcit.ru> Date: Mon, 26 Jul 1999 10:16:54 +0600 From: Don Yury X-Mailer: Mozilla 4.61 [en] (Win98; I) X-Accept-Language: ru,en MIME-Version: 1.0 To: pgsql-sql@postgreSQL.org Subject: Re: [SQL] database design SQL prob. References: Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit "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