dongmo2324 2017-09-25 14:20
浏览 16
已采纳

如何在一列更新mysql时限制另一列的更新?

i have table called post_data having username,email,pass,cam_name,upd_date(of type datatime) fields in that. but the problem is when i insert username, email pass into the table that upd_date(datatime) is updated with current data and time. how can i restrict that ...

I even change the datatype form DATETIME to TIMESTAMP

No use..still it stores current date and time when i update only certain columns.

can any tell me ...

this is my table structure in mysql database

enter image description here

  • 写回答

1条回答 默认 最新

  • dongpu1879 2017-09-25 14:23
    关注

    You have set the default datetime for that column. You need to alter the column.

     alter table post_data alter column upd_date drop default;
    

    If your column doesn't accept NULL, then it will implicitly set default value. You need to alter you table to allow null.

    Data Type Default Values

    If a column definition includes no explicit DEFAULT value, MySQL determines the default value

    ALTER TABLE post_data MODIFY upd_date datetime null;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?