Page 1 of 1

Reseting all fields

Posted: Sat Nov 19, 2005 9:30 pm
by InnerShadow
I was wondering if there was a easier way to reset all of the values in a table back to 0 instead of a very long set of UPDATE statements?

Posted: Sat Nov 19, 2005 10:48 pm
by josh
Do the fields have default values? Delete the row and create a new one with the same primary key

Posted: Sun Nov 20, 2005 6:01 am
by onion2k
jshpro2 wrote:Do the fields have default values? Delete the row and create a new one with the same primary key
Or use "REPLACE (primary_key) values ('1');" where primary_key is the name of the primary key column. This would set all the fields to the default rather than 0 though. Should be a little faster than a delete and an insert.