mysql 時(shí)間列自動插入當(dāng)前日期時(shí)間
用current_timestamp,不過這個(gè)默認(rèn)值只用在timestamp的列伤疙,對datetime列無效例子:
create table default_time ( id int not null primary key auto_increment, name varchar(20) default 'chenlb', my_time timestamp default current_timestamp);
注意:一個(gè)表只能有一個(gè)timestamp列的默認(rèn)值為當(dāng)前日期時(shí)間。
測試插入時(shí)黍特,該時(shí)間列不設(shè)置就行锯蛀;如下列名time為自動插入時(shí)間列: