FAQ
Is there a way to make a conditional ALTER TABLE command?

If I want to drop a column only if that table's column exists, what
would be the correct syntax. I have tried several IF EXISTS, but I
get an error at "IF". I would like to use the Query tool in pgAdmin
III, if possible. But, if push comes to shove, I'll resort to psql.

As an alternative, how best to tell SQL (Query tool) to continue
processing a script even if an "error" (like no column exists) is
encountered.

Thanks,

Dale

Search Discussions

  • Tom Lane at May 26, 2009 at 11:03 pm

    Dale Seaburg writes:
    Is there a way to make a conditional ALTER TABLE command?
    Nope, no such feature. Consider writing a plpgsql function that
    contains whatever logic you need.
    As an alternative, how best to tell SQL (Query tool) to continue
    processing a script even if an "error" (like no column exists) is
    encountered.
    psql will do that happily enough.

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedMay 26, '09 at 10:59p
activeMay 26, '09 at 11:03p
posts2
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Dale Seaburg: 1 post Tom Lane: 1 post

People

Translate

site design / logo © 2022 Grokbase