Home > Archive > PostgreSQL SQL > November 2006 > Problem in recreating primary key.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem in recreating primary key.
Santosh

2006-11-24, 7:16 pm

Hi All,

Setup is:
OS : Sun Solaris 5.8.
Postgres : 7.2.4.

Please help me in following problem.
I have large database which contain 15 tables.
Each table contains 10 to 300 columns. (Avg 200 column).

These tables are updating frequently and some times columns which
should be part of primary key get added into table.
As there is no support in 7.2.4 to add 'not null' constraint in
following manner.
SQL: alter table t1 add column c3 not null; (This is not supported in
7.2.4).

And because of that following SQL get failed.

alter table t1 add constraint t1_pkey primary key (c1,c2,c3);

It give error that c3 is not null.

I find one workaround for this on net:
http://svr5.postgresql.org/pgsql-sq...10/msg00249.php
====================
====================
====
Content of above URL:
In 7.3 there will be a fully implemented ALTER TABLE command for
making
columns null or not null.

Currently you can update 'attnotnull' of pg_attribute system catalog
for the attrelid and attname. use pg_class system catalog for getting
attrelid of a given relation.
====================
====================
====

I have tried to update system table pg_attribute and found that its
working.
But also found, some times it failes with following error:
ERROR: cannot create t1_pkey: File exists

Can any one help me to resolve this issue?

Thanks in advance,

Santosh.

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com