Re: Adding a Primary Key to an exisiting table
От | Bhuvan A |
---|---|
Тема | Re: Adding a Primary Key to an exisiting table |
Дата | |
Msg-id | Pine.LNX.4.44.0301031046090.1186-100000@Bhuvan.bksys.co.in обсуждение исходный текст |
Ответ на | Adding a Primary Key to an exisiting table (Maly Kaing <mkaing1@gl.umbc.edu>) |
Список | 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
В списке pgsql-sql по дате отправления: