I want to update a column with a default value. I do that like so:
ALTER TABLE `db`.`tbl` ALTER COLUMN `some_timestamp` SET DEFAULT current_timestamp();
that works fine. I also want to add NOT NULL. How do I do that?
I want to update a column with a default value. I do that like so:
ALTER TABLE `db`.`tbl` ALTER COLUMN `some_timestamp` SET DEFAULT current_timestamp();
that works fine. I also want to add NOT NULL. How do I do that?
Like so:
ALTER TABLE `db`.`tbl` MODIFY `some_timestamp` TIMESTAMP NOT NULL DEFAULT current_timestamp();
ALTER COLUMN is only used for setting defaults in MySQL; MODIFY <colname> <colspec> modifies a column spec but doesn't rename it. To rename also, use CHANGE <oldname> <newname> <colspec> and specify oldname newname