SybaseDB , change the default value of an existing column in a table

jonjonjonjuice picture jonjonjonjuice · Sep 29, 2010 · Viewed 17.1k times · Source

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.

Answer

AdamH picture AdamH · Sep 30, 2010

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