Skip to content

Instantly share code, notes, and snippets.

@malys
Last active November 30, 2017 10:19
Show Gist options
  • Save malys/ed1d468efb1323f440c9 to your computer and use it in GitHub Desktop.
Save malys/ed1d468efb1323f440c9 to your computer and use it in GitHub Desktop.
[SQL Tips] #sql
IF EXISTS ( SELECT * FROM information_schema.columns WHERE table_name = 'country' AND column_name = 'created_at' AND table_schema = DATABASE() ) THEN
ALTER TABLE `country` DROP COLUMN `created_at`;
END IF;
Because DROP COLUMN IF EXISTS isn't supported by MySQL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment