[ale] mysql sql question
Mike Harrison
cluon at geeklabs.com
Fri Dec 17 02:56:10 EST 2010
On Fri, 17 Dec 2010, Richard Bronosky wrote:
> I disagree with the choice to separate date and time instead of just
> having a single datetime. But I will forgive that. The reason is that
Richard's a very forgiving guy, and good enough to use the date and time
in two fields without going more insane.
Years ago I found that it was handy to have two fields in "time important"
tables such as transactions, gl entries, etc..
My important MySQL tables often have:
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`lastmod` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created` is set to now() during inserts, `lastmod` is a lifesaver during
audits or troubleshooting, or reports about when something was last
accessed modified.
MySQL < 4 sucked at date math, 5+ is pretty darn good at it.
I'd merge the two columns into one datetime.
More information about the Ale
mailing list