建表語(yǔ)句
CREATE table if not exists "test_table" (
"name" TEXT,
"age" TEXT,
"create_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP(0),
"update_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP(0)
);
- 實(shí)現(xiàn):
- 創(chuàng)建帶create_at和update_at字段的表陶缺,字段默認(rèn)值為精度為0的CURRENT_TIMESTAMP点额,保證數(shù)據(jù)在插入時(shí)默認(rèn)會(huì)同時(shí)記錄當(dāng)前時(shí)間為創(chuàng)建時(shí)間和更新時(shí)間
- 在插入語(yǔ)句的時(shí)候判斷當(dāng)數(shù)據(jù)重復(fù)時(shí)舔株,更新update_at字段即可