[thelist] MYSQL - Add field to table with data for existing records

M. Seyon evolt07 at delime.com
Thu Oct 12 10:43:15 CDT 2006


[resend, not sure if this made it through earlier this week, apologies if 
anyone sees it twice]

Need some quick mysql help. I'm sure this is a fairly straightforward request.

I would like to add a field to an existing table, with the following caveats:
- For all existing records, the field needs to be given a value - fixed 
value, same for every record
- But I don't want this value to become the default value for subsequent 
records (added after the new field)

For reference, the field is a year. All existing records need to be set to 
2006. Future records will of course be set to the relevant year, which will 
not be 2006.

I know I can use the ALTER command to add the field, but not sure how to 
add the value.

I also know I can do this with two statements - first ALTER then UPDATE but 
wondering if it can be done in one go.


More information about the thelist mailing list