Re: Rename or Re-Create Constraints? - Mailing list pgsql-general

From Tom Lane
Subject Re: Rename or Re-Create Constraints?
Date
Msg-id 4167.1302368329@sss.pgh.pa.us
Whole thread Raw
In response to Re: Rename or Re-Create Constraints?  (Carlos Mennens <carlos.mennens@gmail.com>)
Responses Re: Rename or Re-Create Constraints?
List pgsql-general
Carlos Mennens <carlos.mennens@gmail.com> writes:
> On Fri, Apr 8, 2011 at 8:35 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I believe you can rename the underlying indexes and the constraints will
>> follow them. �(This works in HEAD anyway, not sure how far back.)

> I renamed the table name from 'accounts' to 'marketing' however all
> the constraints listed under 'indexes' are still named 'accounts_*'
> and I've tried to rename them but I can't find any information with an
> example command to rename the constraints:

ALTER INDEX accounts_pkey RENAME TO whatever

On very old versions of PG you may have to spell that "ALTER TABLE"
instead of "ALTER INDEX", but it's the same thing either way.

            regards, tom lane

pgsql-general by date:

Previous
From: Carlos Mennens
Date:
Subject: Re: Rename or Re-Create Constraints?
Next
From: Carlos Mennens
Date:
Subject: Re: Rename or Re-Create Constraints?