0

私は次のSQLステートメントを試しています:

create table sample (
id int not null primary key auto_increment,
name varchar(100),
date_modified timestamp not null default current_timestamp on update current_timestamp,
date_created timestamp not null default now()
)

動作していません...次のエラーが発生します:

#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

2つの日付スタンプを追跡する必要があります。1つは行が作成された日付用で、もう1つは行が最後に変更された日付用です。どちらも私が単独で使用したいことを実行しますが、MySQLではそれらを1つのテーブルに結合することはできません。

助けてください。:)

4

1 に答える 1

0

トリガーBEFORE UPDATEを作成して変更することができますdate_modified

またはBEFORE INSERT、そこで作成しますdate_created

于 2010-12-22T01:25:34.140 に答える