Re: Rename a constraint

From: Thom Brown <thombrown(at)gmail(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Cc: rod(at)iol(dot)ie, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: Rename a constraint
Date: 2011-05-29 13:20:54
Message-ID: BANLkTim2WZR9=w5CcnHpQDUJpbaSQ7jmFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10 January 2009 19:22, Raymond O'Donnell <rod(at)iol(dot)ie> wrote:
> On 10/01/2009 19:15, Thom Brown wrote:
>> I can't find anything in the documentation, but does anyone know if
>> there is a way to rename a constraint?
>
> I just tried it with a primary key...
>
> test=# alter table t1 alter constraint t1_pk rename to t1_pp;
> ERROR:  syntax error at or near "constraint"
> LINE 1: alter constraint t1_pk rename to t1_pp;
>
>
> ... and as you can see it didn't work. I suppose you could always drop
> and recreate it with a different name.

While this was a sufficient solution for the problem I was having back
then, it will be problematic for those with large tables as it means
re-validating the constraint against the entire table.

I notice Bruce submitted a change to allow the renaming of
constraints, but nothing ever came of it:
http://archives.postgresql.org/pgsql-patches/2006-02/msg00168.php

It's also in the TODO: http://wiki.postgresql.org/wiki/Todo#ALTER

Any chance of this being picked up for 9.2? :)

Thom

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2011-05-29 15:12:44 Re: Rename a constraint
Previous Message Tareq Tajkeh 2011-05-29 13:17:18