Does sqlite3 support a trigger to automatically update an 'updated_on' datetime field?

前端 未结 1 1809
庸人自扰
庸人自扰 2021-02-07 18:20

I have a table that looks like this

user_id   |  name   |  created_on   |   updated_on
--------------------------------------------------
1         | Peter D | 1         


        
1条回答
  •  暖寄归人
    2021-02-07 19:16

    CREATE TRIGGER your_table_trig AFTER UPDATE ON your_table
     BEGIN
      update your_table SET updated_on = datetime('now') WHERE user_id = NEW.user_id;
     END;
    

    0 讨论(0)
提交回复
热议问题