pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to rename a constraint/trigger??
2+ messages / 2 participants
[nested] [flat]

* How to rename a constraint/trigger??
@ 2004-09-06 14:03  Andrei Bintintan <klodoma@ar-sd.net>
  0 siblings, 1 reply; 2+ messages in thread

From: Andrei Bintintan @ 2004-09-06 14:03 UTC (permalink / raw)
  To: pgsql-sql; pgsql-admin@postgresql.org

Hi to all,

I have a database, where in the tables I have around 100 constrains (link to other tables) that don't have a name "<unnamed>" or they have a name like "$1" "$2". Now, I have a module which bases on the same structure, but I get some query errors from a "<unnamed>" constraint. I really don't know exaclty  which the constrain generates the error, in that table I have 12 such constrains. 

Does anyone have a script or it exist a command so that I can rename all the "<unnamed>"constrains in this database? 

I'm using postgre 7.3.2.

Thankx,
Andy.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] How to rename a constraint/trigger??
@ 2004-09-08 17:05  Josh Berkus <josh@agliodbs.com>
  parent: Andrei Bintintan <klodoma@ar-sd.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2004-09-08 17:05 UTC (permalink / raw)
  To: Andrei Bintintan <klodoma@ar-sd.net>; pgsql-sql; pgsql-admin@postgresql.org

Andrei,

> I have a database, where in the tables I have around 100 constrains (link
> to other tables) that don't have a name "<unnamed>" or they have a name
> like "$1" "$2". Now, I have a module which bases on the same structure, but
> I get some query errors from a "<unnamed>" constraint. I really don't know
> exaclty  which the constrain generates the error, in that table I have 12
> such constrains.

You'll be happy to know that in 7.4 we stopped using "<unnamed>".

> Does anyone have a script or it exist a command so that I can rename all
> the "<unnamed>"constrains in this database?

You can't rename constraints, you have to drop and re-create them under a new 
name (do this in a transaction for data safety).  However, this requires 
knowing what all those constraints do.   I'd suggest doing a text pg_dump 
file of your schema only (no data) and looking in the constraints section at 
the end.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-09-08 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-06 14:03 How to rename a constraint/trigger?? Andrei Bintintan <klodoma@ar-sd.net>
2004-09-08 17:05 ` Josh Berkus <josh@agliodbs.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