Hi, On 20 September 2011 13:09, patrick keshishian <pkeshish@xxxxxxxxx> 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 ... -A -t -c "SELECT 'ALTER TABLE sales DROP CONSTRAINT ' || conname || ';' FROM pg_constraint JOIN pg_class ON (conrelid=pg_class.oid) WHERE pg_class.relname='sales' AND conkey[1] = 1 AND contype='f'" Finally, you can save it in to file or pipe it to another psql: psql ... -A -t -c '....' | psql ... -- Ondrej Ivanic (ondrej.ivanic@xxxxxxxxx) -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general