如何插入表SET数据类型?
[当我尝试在MySQL中插入SET数据时-成功插入(没有警告或错误),但是我得到了空单元格,而不是被数据填充。
我尝试过这样:
INSERT INTO `individual_rate`(`user_id`, `movie_id`, `rate_code`, `rate_parts`)
VALUES (3, 13,('1, 0, 0, 0, 0, 0'),('81, 102, 0, 102'))
也尝试过这样:
INSERT INTO `individual_rate`(`user_id`, `movie_id`, `rate_code`, `rate_parts`)
VALUES (3, 13,'1, 0, 0, 0, 0, 0','81, 102, 0, 102')
[将数据插入到user_id
和movie_id
中,但没有为rate_code
和rate_parts
做它
表结构:
CREATE TABLE `individual_rate` (
`user_id` int(11) NOT NULL,
`movie_id` int(11) NOT NULL,
`rate_code` set('n','a','f','d','s','e') COLLATE utf8_unicode_ci NOT NULL COMMENT 'rate code',
`rate_parts` set('top_f','bottom_f','top_a','bottom_a') COLLATE utf8_unicode_ci NOT NULL COMMENT 'generated parts'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
我做错了什么?
您可以使用show warnings;
查看发生了什么。
这里是结果,
show warnings;
+---------+------+-------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------+
| Warning | 1265 | Data truncated for column 'rate_code' at row 1 |
| Warning | 1265 | Data truncated for column 'rate_parts' at row 1 |
+---------+------+-------------------------------------------------+