September 30, 2022 at 12:00 am
Comments posted to this topic are about the item Idempotent Column Drops
September 30, 2022 at 8:34 am
Maybe I've misunderstood but wouldn't it be prudent to check that the table exists before attempting to alter a column?
October 1, 2022 at 10:40 pm
That's what alter table drop column if exists does.
October 3, 2022 at 8:52 am
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
October 3, 2022 at 8:55 am
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.
October 3, 2022 at 3:34 pm
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