我已经创建了一个表,在该表中,我在创建表时将列payment_time设置为TIMESTAMP DEFAULT CURRENT_TIMESTAMP。
当我插入值时,我用''将payment_time设置为空。但是,当我检查payment_time上的表显示0000-00-00 00:00:00时,我正在查找当前时间。我是不是搞错了?
发布于 2013-02-03 07:01:39
尝尝这个
payment_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP并修改insert语句,如下所示
INSERT INTO TB (`payment_time`) VALUES ('NOW()' );
--dont specifie the id column it will be automatically inserted编辑。
INSERT INTO TB (`col1`, `col2`,`payment_time`) VALUES ('somevalue1','somevalue2','NOW()' );
-- dont use the id column just the other columns , and be sure that columns are in right ORDER由于您编辑的问题,以下是解决方案
INSERT INTO donors (firstName,lastName,gender,email,amount,currency)VALUES( 'MD.Borhan', 'Safa', 'm', 'borhansafa@yahoo.com', '5', 'GBP' );发布于 2016-06-18 20:22:15
payment_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP使用它,然后不要在insert语句中使用payment_time。当前日期将自动分配给您各自的条目。
https://stackoverflow.com/questions/14667346
复制相似问题