Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-20 Thread patrick keshishian
On Tue, Sep 20, 2011 at 7:36 AM, Adrian Klaver wrote: > On Monday, September 19, 2011 8:09:04 pm patrick keshishian wrote: >> On Mon, Sep 19, 2011 at 6:08 PM, Adrian Klaver > wrote: >> > On Monday, September 19, 2011 5:10:45 pm patrick keshishian wrote: >> >> Hi, >> >> >> >> Is there any way the

Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-20 Thread Adrian Klaver
On Monday, September 19, 2011 8:09:04 pm patrick keshishian wrote: > On Mon, Sep 19, 2011 at 6:08 PM, Adrian Klaver wrote: > > On Monday, September 19, 2011 5:10:45 pm patrick keshishian wrote: > >> Hi, > >> > >> Is there any way the .sql scripts could make use of this query to get > >> the fore

Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-19 Thread patrick keshishian
On Mon, Sep 19, 2011 at 8:34 PM, Tom Lane wrote: > patrick keshishian writes: >> The question wasn't where does one find the name of the constraint. My >> example demonstrated that I knew how to get that value. The question, >> however, is how do you get that in an ALTER TABLE statement? > > You'

Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-19 Thread patrick keshishian
2011/9/19 Ondrej Ivanič : > Hi, > > On 20 September 2011 13:09, patrick keshishian wrote: >> e.g., ALTER TABLE sales DROP CONSTRAINT (SELECT conname FROM >> pg_constraint JOIN pg_class ON (conrelid=pg_class.oid) WHERE >> pg_class.relname='sales' AND conkey[1] = 1 AND contype='f') ; > > You have to

Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-19 Thread Tom Lane
patrick keshishian writes: > The question wasn't where does one find the name of the constraint. My > example demonstrated that I knew how to get that value. The question, > however, is how do you get that in an ALTER TABLE statement? You'd need to construct the ALTER statement as a string value

Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-19 Thread Ondrej Ivanič
Hi, On 20 September 2011 13:09, patrick keshishian wrote: > e.g., ALTER TABLE sales DROP CONSTRAINT (SELECT conname FROM > pg_constraint JOIN pg_class ON (conrelid=pg_class.oid) WHERE > pg_class.relname='sales' AND conkey[1] = 1 AND contype='f') ; You have to build query in different way: psql

Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-19 Thread patrick keshishian
On Mon, Sep 19, 2011 at 6:08 PM, Adrian Klaver wrote: > On Monday, September 19, 2011 5:10:45 pm patrick keshishian wrote: >> Hi, >> >> Is there any way the .sql scripts could make use of this query to get >> the foreign key name from pg_constraint table, regardless of PG >> version (7.4.x or 9.x)

Re: [GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-19 Thread Adrian Klaver
On Monday, September 19, 2011 5:10:45 pm patrick keshishian wrote: > Hi, > > > > Is there any way the .sql scripts could make use of this query to get > the foreign key name from pg_constraint table, regardless of PG > version (7.4.x or 9.x)? Use the information schema? As example: http://www

[GENERAL] Dynamic constraint names in ALTER TABLE

2011-09-19 Thread patrick keshishian
Hi, Where I work, we have a large deployment of software using PostgreSQL database. We have been stuck on version 7.4.16 for a while now. I am about to switch us to a 9.0.x. One problem I'm running into, and I am hoping you can help me with, given the constraints I have to work with, is our conve