How do I add current date to existing table for each row??

Accepted Answer

ALTER tableName ADD (DateField DATE);
UPDATE tableName SET DateField = CURDATE();

If you want the current time also, change Date to DATETIME & CURDATE() to NOW()

Note: If you are using php (as tagged in the question) It may be quicker to alter the table with the current time:

$dtFormatted = date("Y-m-d"); //php code

ALTER tableName ADD (DateField DATE DEFAULT '{$dtFormatted}');
ALTER tableName MODIFY DateField DATE DEFAULT NULL;
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki