Re: Rename or Re-Create Constraints?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Rename or Re-Create Constraints?
Date: 2011-04-09 16:58:49
Message-ID: 4167.1302368329@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com> writes:
> On Fri, Apr 8, 2011 at 8:35 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Carlos Mennens 2011-04-09 21:59:06 Re: Rename or Re-Create Constraints?
Previous Message Carlos Mennens 2011-04-09 16:22:37 Re: Rename or Re-Create Constraints?