0
我在看一些練習題,MySQL的時間戳問題
Assume that you've just created this table: CREATE TABLE timestamptest ( ts1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, i INT ); When you look at its structure, you will notice that the TIMESTAMP column is declared NOT NULL. What happens if you insert these records: mysql> INSERT INTO timestamptest SET ts1=NULL, i=10; mysql> INSERT INTO timestamptest SET ts1=0, i=11; mysql> INSERT INTO timestamptest SET ts1='', i=12;
俺們是
Only the first statement succeeds, and the TIMESTAMP column is set to the current date and time. The other two statements give an error: mysql> INSERT INTO timestamptest SET ts1=NULL, i=10; Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO timestamptest SET ts1=0, i=11; ERROR 1292 (22007): Incorrect datetime value: '0' for column 'ts1' at row 1 mysql> INSERT INTO timestamptest SET ts1='', i=12; ERROR 1292 (22007): Incorrect datetime value: '' for column 'ts1' at row 1
但是當我試圖,將TS1 = 0的作品,它插入一個零值時間戳...答案錯了嗎?