Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
987 views
in Technique[技术] by (71.8m points)

mysql - Timestamp without change on update

In mysql I have a timestamp with the field name added_on. I created that for a table of leads for a crm. But it's getting updated whenever I update a lead. I only want the timestamp to show only the added time. I dont want that to get updated everytime when I update or make changed in the lead.

Note: while creating the timestamp field i gave default value as timestamp and it shows ON UPDATE CURRENT_TIMESTAMP in the extras field after creating the field.

any ideas to stop the timestamp getting updated whenever I update the row?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The issue is the ON UPDATE CURRENT_TIMESTAMP. You should be able to undo this behavior with an alter statement like this (not sure what your table name is):

ALTER TABLE leads MODIFY added_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...