Timestamp Field not Auto Update
I have a registration table with a timestamp field that I want to use the current timestamp when someone registers. If you just create a timestamp field in mysql, it acts as though you did:
`regdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMPThis is fine and dandy for some applications, but any time you update the record, it will update the timestamp. I did not want this. So, you can just create the table with:
`regdate` timestamp NOT NULL default CURRENT_TIMESTAMPBut, if like me, you have to alter the table, it' simple enough to do with:
ALTER TABLE registration CHANGE regdate regdate timestamp default CURRENT_TIMESTAMP;
Resources:
No comments:
Post a Comment