Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 798
jonjonjonjuice Avatar asked Sep 29 '10 17:09

jonjonjonjuice


1 Answers

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
like image 151
AdamH Avatar answered Oct 01 '22 18:10

AdamH