这不起作用:
INSERT INTO `catalog_product_entity` VALUES
(28,4,4,'simple','BCBSO2R',0,0,'2012-03-25 02:52:08','2015-05-19 12:20:53')
1292 - 日期时间值不正确:“2012-03-25 02:52:08”列 第1行'created_at'
但这有效:
INSERT INTO `catalog_product_entity` VALUES
(28,4,4,'simple','BCBSO2R',0,0,'2012-03-25 01:52:08','2015-05-19 12:20:53')
我只改变了从'2012-03-25 02:52:08'到'2012-03-25 01:52:08'的时间!!
表列created_at
中的具体值如何可能TIMESTAMP空DEFAULT空注释'创建时间';是不允许的?
编辑:(完全创建语法)
DROP TABLE IF EXISTS `catalog_product_entity`;
CREATE TABLE `catalog_product_entity` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
`entity_type_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Entity Type ID',
`attribute_set_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Attribute Set ID',
`type_id` varchar(32) NOT NULL DEFAULT 'simple' COMMENT 'Type ID',
`sku` varchar(64) DEFAULT NULL COMMENT 'SKU',
`has_options` smallint(6) NOT NULL DEFAULT '0' COMMENT 'Has Options',
`required_options` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Required Options',
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Creation Time',
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Update Time',
PRIMARY KEY (`entity_id`),
KEY `IDX_CATALOG_PRODUCT_ENTITY_ENTITY_TYPE_ID` (`entity_type_id`),
KEY `IDX_CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID` (`attribute_set_id`),
KEY `IDX_CATALOG_PRODUCT_ENTITY_SKU` (`sku`),
CONSTRAINT `FK_CAT_PRD_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_CAT_PRD_ENTT_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID` FOREIGN KEY (`entity_type_id`) REFERENCES `eav_entity_type` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1510 DEFAULT CHARSET=utf8 COMMENT='Catalog Product Table';
答案 0 :(得分:1)
问题是由于夏令时的变化,日期/时间不存在(给定配置服务器)。
测试:
mysql> DROP TABLE IF EXISTS `catalog_product_entity`;
Query OK, 0 rows affected (0,00 sec)
mysql> CREATE TABLE `catalog_product_entity` (
-> `id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
-> `created_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Creation Time'
-> );
Query OK, 0 rows affected (0,01 sec)
mysql> SET GLOBAL time_zone := 'UTC';
Query OK, 0 rows affected (0,00 sec)
mysql> SET time_zone := 'UTC';
Query OK, 0 rows affected (0,00 sec)
mysql> SHOW VARIABLES LIKE '%time_zone%';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| system_time_zone | UTC |
| time_zone | UTC |
+------------------+-------+
2 rows in set (0,00 sec)
mysql> INSERT INTO `catalog_product_entity`
-> (`created_at`)
-> VALUES
-> ('2012-03-25 02:52:08');
Query OK, 1 row affected (0,00 sec)
mysql> SET GLOBAL time_zone := 'Europe/Berlin';
Query OK, 0 rows affected (0,00 sec)
mysql> SET time_zone := 'Europe/Berlin';
Query OK, 0 rows affected (0,00 sec)
mysql> SHOW VARIABLES LIKE '%time_zone%';
+------------------+---------------+
| Variable_name | Value |
+------------------+---------------+
| system_time_zone | UTC |
| time_zone | Europe/Berlin |
+------------------+---------------+
2 rows in set (0,00 sec)
mysql> INSERT INTO `catalog_product_entity`
-> (`created_at`)
-> VALUES
-> ('2012-03-25 02:52:08');
ERROR 1292 (22007): Incorrect datetime value: '2012-03-25 02:52:08' for column 'created_at' at row 1
日期/时间' 2012-03-25 02:52:08'例如,由于夏令时的变化,柏林无效。请参阅Clock Changes in Berlin, Berlin, Germany in 2012。
11.3.1 The DATE, DATETIME, and TIMESTAMP Types
...
MySQL将TIMESTAMP值从当前时区转换为UTC 存储,并从UTC返回到当前时区进行检索。 (对于其他类型,例如DATETIME,不会出现这种情况。)
...