Reputation: 9338
What's better in MySQL and why:
to set up
`Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
when creating a table
Or:
INSERT Now() value when we insert a row.
Added: What about the performance?
Upvotes: 4
Views: 3787
Reputation: 753
I have gone through this document Bug in now() and current_timestamp()
I would suggest to use either now() or current_timestamp() function through out the project.
Upvotes: 0
Reputation: 72676
If the Time field is mandatory and should never be null or not set is better to enforce it in the table structure (solution 1), instead if the field can be omitted sometimes you should use NOW() in the insert query. It depends on your needs ...
Upvotes: 1
Reputation: 1026
I suggest having the DB do the work, that way a programmer can't forget to do the extra column insert/update and insert an incorrect time.
Upvotes: 5