Skip site navigation (1) Skip section navigation (2)

Re: how to create secondary key!!

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: "Nelson Yong" <nelsonyong(at)ipmuda(dot)com(dot)my>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to create secondary key!!
Date: 2002-10-24 16:49:20
Message-ID: web-1798058@davinci.ethosmedia.com (view raw or flat)
Thread:
Lists: pgsql-novice
Nelson,

> If i migrate the database from Text file using pgadmin tools,the
> table 
> and data record will be created automatically and no primary key
> assign 
> so now i need to assign the key but unfortunely i can't change the
> field 
> property. i.e. I can't assign "two-column primary key." 

You'll need to use the command line for this.  Open an ad-hoc query
window from PGAdminII (the wierd-looking monster).   Run the following
command:

ALTER TABLE table_name ADD CONSTRAINT table_name_PK
PRIMARY KEY (column_1, column_2);

... where you replace table_name, column_1 and column_2 with the
appropriate objects from your database.

BTW, the above command will fail if it turns out that the combination
of column_1 and column_2 is not unique, or if either column has NULLs.

-Josh Berkus


pgsql-novice by date

Next:From: Josh BerkusDate: 2002-10-24 16:54:23
Subject: Re: Postgres and Sybase
Previous:From: Duncan Adams (DNS)Date: 2002-10-24 11:36:37
Subject: function problems.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group