From: | Bhuvan A <bhuvansql(at)myrealbox(dot)com> |
---|---|
To: | Maly Kaing <mkaing1(at)gl(dot)umbc(dot)edu> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Adding a Primary Key to an exisiting table |
Date: | 2003-01-03 05:20:57 |
Message-ID: | Pine.LNX.4.44.0301031046090.1186-100000@Bhuvan.bksys.co.in |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> Hi
>
> I just exported my MS Access databases into postgres using an ODBC driver,
> but the thing is during the export postgres doesn't recognize any of my
> primary keys in Access.
> Is there any way to alter the tables so that i can make one of my current
> fields the primary key? I don't want to drop the column since I already
> have data in the table and i don't want to create/drop tables as some of
> the documentation suggests since most of my tables have 10+ fields.. any
> suggestions??
>
AFAIK, it can be done in any of the below two ways:
1. Create unique index
CREATE UNIQUE INDEX index_name ON table_name USING btree (field1, ..,
fieldn);
2. Add primary key constraint
ALTER TABLE table_name ADD PRIMARY KEY (field1, .., fieldn);
For this to happen, the fields should have unique values.
regards,
bhuvaneswaran
From | Date | Subject | |
---|---|---|---|
Next Message | Manfred Koizar | 2003-01-03 13:10:18 | Re: NULLL comparison in multiple column unique index |
Previous Message | Brian Walker | 2003-01-02 23:19:52 | NULLL comparison in multiple column unique index |