SQL timestamps: ON UPDATE do nothing?

Discuss other programming languages besides AutoHotkey
Miguel7
Posts: 186
Joined: 08 Sep 2014, 07:06

SQL timestamps: ON UPDATE do nothing?

27 Feb 2018, 17:07

Hey guys,

I've been dealing with a bizarre and frustrating problem on my web server (it's a LAMP stack) where for some reason, every time you create a field of type TIMESTAMP (from the UI, from SQL code, or programmatically from PHP) it makes a unilateral decision that I absolutely need to add "ON UPDATE CURRENT_TIMESTAMP" to the syntax. This means that every time I update a record with a timestamp (even if I'm not changing it), that timestamp will automatically be forced to be = the current date/time. I Googled up a workaround...

ALTER TABLE table_name
CHANGE column_name
column_name TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP

..but I'm guessing there's some super-simple bit of SQL I can use in CREATE TABLE queries to prevent this wackadellic behavior altogether... or is there? Any of you ever fought with this one before? How did you get it to stop inserting "ON UPDATE CURRENT_TIMESTAMP" because it felt like it? Any clues as to the actual cause of this bug? Thanks in advance :)

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 28 guests