I have a table called "downloads" with a few thousand rows. I just added a column called is_completed using the following command:
ALTER TABLE downloads ADD is_completed BIT default 1 NOT NULL
Now I would like to change the default value for is_completed to 0 - I tried this command to no avail:
ALTER TABLE downloads MODIFY is_completed default 0
This does not work, it says I have incorrect syntax near default. I can't seem to google this for the life of me. Anyone know the correct syntax? I want all future rows added to this table to have is_completed default to 0 if an explicit value is omitted.
To alter a default you need to use replace rather than modify:
alter table downloads replace is_completed default 0
If you need to change the data type or the null/not null then you should use
alter table t modify c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With