pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: [SQL] Drop NOT NULL constraint !!!
3+ messages / 3 participants
[nested] [flat]
* Re: [SQL] Drop NOT NULL constraint !!!
@ 2002-11-20 19:17 ` mallah@trade-india.com
2002-11-21 11:01 ` Re: Drop NOT NULL constraint !!! Ludwig Lim <lud_nowhere_man@yahoo.com>
1 sibling, 1 reply; 3+ messages in thread
From: mallah@trade-india.com @ 2002-11-20 19:17 UTC (permalink / raw)
To: rene@ibiz.com.br; +Cc: pgsql-general@postgresql.org; pgsql-sql
do a \d tablename
for the name of the contraint.
say its $1
the do
psql> alter table <tablename> drop contstraint "$1" RESTRICT;
> Does anybody could tell me how to drop a constraint on a column where no name was provided to
> the constraint? How does Pg name constraints?
>
> Thanks
> --
> Renê Salomão
> Ibiz Tecnologia -- www.ibiz.com.br
>
>
> ---------------------------(end of broadcast)--------------------------- TIP 6: Have you
> searched our list archives?
>
> http://archives.postgresql.org
-----------------------------------------
Get your free web based email at trade-india.com.
"India's Leading B2B eMarketplace.!"
http://www.trade-india.com/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Drop NOT NULL constraint !!!
2002-11-20 19:17 ` Re: [SQL] Drop NOT NULL constraint !!! mallah@trade-india.com
@ 2002-11-21 11:01 ` Ludwig Lim <lud_nowhere_man@yahoo.com>
0 siblings, 0 replies; 3+ messages in thread
From: Ludwig Lim @ 2002-11-21 11:01 UTC (permalink / raw)
To: mallah@trade-india.com; +Cc: pgsql-sql
--- mallah@trade-india.com wrote:
>
> do a \d tablename
>
> for the name of the contraint.
> say its $1
> the do
>
> psql> alter table <tablename> drop contstraint "$1"
> RESTRICT;
>
I alter a table with by adding a foriegn key
constraint.
ALTER TABLE sc_city ADD CONSTRAINT cons_fkey
FOREIGN KEY state_cd REFERENCE sc_state(state_cd);
After altering the table I executed
"\d <table name>" show the following:
Triggers: RI_ConstraintTrigger_56743429
I'm surprised that name of constraint doesn't appear
even though I explictly name it. Is there a way to
show the name of the constraint?
Should I do :
ALTER TABLE sc_city DROP CONSTRAINT
RI_ConstraintTrigger+5674329 RESTRICT ?
Thank you very much,
ludwig
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Drop NOT NULL constraint !!!
@ 2002-11-21 06:53 ` Mario Weilguni <mweilguni@sime.com>
1 sibling, 0 replies; 3+ messages in thread
From: Mario Weilguni @ 2002-11-21 06:53 UTC (permalink / raw)
To: pgsql-general@postgresql.org
Am Mittwoch, 20. November 2002 20:09 schrieb RenX SalomXo:
> Does anybody could tell me how to drop a constraint on a column where no
> name was provided to the constraint? How does Pg name constraints?
>
> Thanks
did you add a "CHECK" constraint, or did you use "NOT NULL" in the table definition? For the not null case it's easy:
update pg_attribute
set attnotnull=false
where attname='yourattributename'
and attrelid=(select oid from pg_class where relname='mytable' and relkind='r');
If you added a check constraint, you have to remove the corresponding row from pg_relcheck
and decrement the attribute "relchecks" in pg_class for the table, but I won't do it without having
a backup at hand.
Backup your data first.
Regards,
Mario Weilguni
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-11-21 11:01 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-20 19:17 ` mallah@trade-india.com
2002-11-21 11:01 ` Ludwig Lim <lud_nowhere_man@yahoo.com>
2002-11-21 06:53 ` Mario Weilguni <mweilguni@sime.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox