Idempotent Column Drops

  • Comments posted to this topic are about the item Idempotent Column Drops

  • Maybe I've misunderstood but wouldn't it be prudent to check that the table exists before attempting to alter a column?

  • That's what alter table drop column if exists does.

  • It only checks on column. If table does not exist statement will fail. So in fact old-style if checking on information_schema.columns would be more bulletproof as you can search for both table and column there

  • Piotr ER wrote:

    It only checks on column. If table does not exist statement will fail. So in fact old-style if checking on information_schema.columns would be more bulletproof as you can search for both table and column there

    That's what I thought - hence my initial comment.

  • I guess you might need to check the table exists. Sorry, I saw this on mobile and missed the "table" note in your comment.

    Hadn't thought about checking for a table as a drop column would always be against a table that exists, but since you might accidentally run this code twice, you'd need to check for a column existence.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply