Thread: alter table and constraints

alter table and constraints

From
"Martin A. Marques"
Date:
I don't know if this is posible, but I'm trying to add and delete
constrains from a table. Is this posible and why am I having so much
problems?

TIA


"And I'm happy, because you make me feel good, about me." - Melvin Udall
-----------------------------------------------------------------
Martín Marqués            email:     martin@math.unl.edu.ar
Santa Fe - Argentina        http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------


Re: alter table and constraints

From
Stephan Szabo
Date:
On Fri, 25 Aug 2000, Martin A. Marques wrote:

> I don't know if this is posible, but I'm trying to add and delete
> constrains from a table. Is this posible and why am I having so much
> problems?

In 7.0 you can add foreign key constraints with ALTER TABLE, but you
cannot add other constraints or remove constraints with it.  Some
constraints can be added or removed in other ways, what are you trying to
do precisely?

[In current sources you should also be able to add check constraints.]


Re: alter table and constraints

From
"Martin A. Marques"
Date:
On Fri, 25 Aug 2000, Peter Eisentraut wrote:

> Martin A. Marques writes:
>
> > I don't know if this is posible, but I'm trying to add and delete
> > constrains from a table. Is this posible and why am I having so much
> > problems?
>
> Because it only works for foreign keys. If you are talking about foreign
> key contraints then you should define "problems" better.

No, it was a primary key.
Can I change the constraint of NULL in a column? And what should I do if
I want to add a primary key to a table?


"And I'm happy, because you make me feel good, about me." - Melvin Udall
-----------------------------------------------------------------
Martín Marqués            email:     martin@math.unl.edu.ar
Santa Fe - Argentina        http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------


Re: alter table and constraints

From
Stephan Szabo
Date:
On Fri, 25 Aug 2000, Martin A. Marques wrote:

> On Fri, 25 Aug 2000, Peter Eisentraut wrote:
>
> > Martin A. Marques writes:
> >
> > > I don't know if this is posible, but I'm trying to add and delete
> > > constrains from a table. Is this posible and why am I having so much
> > > problems?
> >
> > Because it only works for foreign keys. If you are talking about foreign
> > key contraints then you should define "problems" better.
>
> No, it was a primary key.
> Can I change the constraint of NULL in a column? And what should I do if
> I want to add a primary key to a table?

Well, you can add a unique index to the columns and set attnotnull in
pg_attribute which should probably work for the not null portion.  That's
basically what the primary key constraint is.