tags:

views:

1033

answers:

3

I just added a new column in my DB which I need to propagate with a specific text value (Confirmed). Is there a simple way to apply to all my data entries so I don't have to go through all my rows and type the value in?

Thanks

+5  A: 

you run the statement:

UPDATE whateveryourtableis SET whateveryourcolumnis = 'whatever';
Dave Markle
This is correct (+1), but be careful. Dave is answering your question specifically, but an UPDATE without a WHERE clause is not generally what you're looking for. :)
JP Alioto
Beware, Russ, as this will overwrite any and all data in the column you update all at once. For large tables, this operation will consume lots of resources, too (disk/memory/log/etc.). I once did this to a table on a machine with low disk space...and there was not fun to be had. I'm talking about huge tables, though...100k-1m+ rows
Michael Haren
Thanks for your help. That did it.
Here's a double barrel shotgun, both barrels filled with double-aught buck and a hair trigger. Don't go shootin' yourself in the foot now...
Dave Markle
+1  A: 

Yes there is:

UPDATE [table]
SET [column] = 'Confirmed'
Jamie Ide
+1  A: 

Yould could make the desired value the new column's DEFAULT e.g.

ALTER TABLE MyTable ADD 
   my_new_column VARCHAR(20) DEFAULT 'Confirmed' NOT NULL;
onedaywhen