我在MySQL有一個表有幾列有指定的默認值,但當我嘗試插入一行,(不指定這些默認列的值),它會引發錯誤,說我不能插入NULL值。MySQL - 不能在列中插入NULL值,但我有指定的默認值?
以下是表格示例;
CREATE TABLE `users` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`UniqueName` varchar(120) NOT NULL,
`Password` varchar(1000) NOT NULL,
`PublicFlag` tinyint(1) NOT NULL,
`NoTimesLoggedIn` int(10) unsigned NOT NULL DEFAULT '0',
`DateTimeLastLogin` timestamp NOT NULL DEFAULT '1971-01-01 00:00:00',
`UserStatusTypeId` int(10) unsigned NOT NULL,
`Private` tinyint(1) NOT NULL DEFAULT '0',
`SiteName` varchar(255) NOT NULL,
`CountryId` int(10) NOT NULL DEFAULT '0',
`TimeZoneId` varchar(255) NOT NULL DEFAULT 'UTC',
`CultureInfoId` int(10) unsigned NOT NULL DEFAULT '0',
`DateCreated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`UserCreated` int(10) unsigned NOT NULL,
`LastUpdatedBy` int(10) unsigned NOT NULL,
`DateLastUpdated` datetime DEFAULT NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `UniqueName_UNIQUE` (`UniqueName`),
KEY `Index 3` (`SiteName`)
)
它抱怨TimeZoneId,當我填充TimeZoneId時,它抱怨CultureInforId。
我使用的MySQL版本:43年1月5日,社區
這裏被插入查詢我試圖插入,從NHibernate的探查抓起:
INSERT INTO Users
(UniqueName,
Password,
PublicFlag,
NoTimesLoggedIn,
DateTimeLastLogin,
SiteName,
TimeZoneId,
DateCreated,
DateLastUpdated,
Private,
CountryId,
CultureInfoId,
UserCreated,
LastUpdatedBy,
UserStatusTypeId)
VALUES ('[email protected]','u1uhbQviLp89P9b3EnuN/Prvo3A4KVSiUa0=',1,
0,'1/01/1971 12:00:00 AM','V9O1T80Q6D',NULL,'2/08/2010 2:13:44 AM',
'2/08/2010 2:13:44 AM',0, NULL, NULL, 4, 4,31)
它只是我還是隻有12個字段,但你試圖插入15個值? – Ross 2010-08-02 03:06:28