Thread: Can primary key be dropped and added back in?

Can primary key be dropped and added back in?

From
Jessica Richard
Date:
I have a huge table to load (30+M rows).

Dropping indexes before loading will speed up my process, but I am not sure about the primary key that was created with the table creation. Is the Postgres primary key treated like an index? If yes, dropping the primary key might help my loading as well.... I can drop the primary key by

alter table tbleName drop constraint pkname_pkey.. it dropped clean this way.

But I haven't found the command to put the primary key back (all for testing now)

Is there a command to add the primary key back after loading the data?

Thanks


Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.

Re: Can primary key be dropped and added back in?

From
"Joshua D. Drake"
Date:
Jessica Richard wrote:
> I have a huge table to load (30+M rows).
>
> Dropping indexes before loading will speed up my process, but I am not
> sure about the primary key that was created with the table creation. Is
> the Postgres primary key treated like an index? If yes, dropping the
> primary key might help my loading as well.... I can drop the primary key by
>
> alter table tbleName drop constraint pkname_pkey.. it dropped clean this
> way.
>
> But I haven't found the command to put the primary key back (all for
> testing now)

alter table foo add primary key (baz);

Joshua D. Drake

>
> Is there a command to add the primary key back after loading the data?
>
> Thanks
>
> ------------------------------------------------------------------------
> Moody friends. Drama queens. Your life? Nope! - their life, your story.
> Play Sims Stories at Yahoo! Games.
> <http://us.rd.yahoo.com/evt=48224/*http://sims.yahoo.com/>


--

       === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive  PostgreSQL solutions since 1997
              http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


Re: Can primary key be dropped and added back in?

From
"Igor Neyman"
Date:
ALTER TABLE tableName ADD CONSTRAINT pkname_pkey (column1, column2, ...);


From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Jessica Richard
Sent: Tuesday, July 17, 2007 2:44 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] Can primary key be dropped and added back in?

I have a huge table to load (30+M rows).

Dropping indexes before loading will speed up my process, but I am not sure about the primary key that was created with the table creation. Is the Postgres primary key treated like an index? If yes, dropping the primary key might help my loading as well.... I can drop the primary key by

alter table tbleName drop constraint pkname_pkey.. it dropped clean this way.

But I haven't found the command to put the primary key back (all for testing now)

Is there a command to add the primary key back after loading the data?

Thanks


Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.