"...ADD COLUMN...DEFAULT YES" leaves existing rows as FALSE?

S

Santiago

Hi all,
I'm adding a new column via this statement:
ALTER TABLE myTable ADD COLUMN myColumn YESNO DEFAULT YES

And it works great except that existing rows have myColumn = FALSE even
though the default is TRUE (new rows behave correctly). I would expect that
existing rows would take on the default? Am I incorrect in my expectation or
is there something wrong in my SQL statement?

P.S.: If you were about to answer: Just use this statement:
UPDATE myTable SET myColumn = YES
save your breath :) I already have done that. The question above still
stands though.
 
A

Allen Browne

The Default Value applies only to new records.

It never has an effect on existing records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top