mysql - ERROR 1062 (23000): Duplicate entry though entries are not duplicate -
table definition:
create table positionaldatangs ( date date, time time(3) , x float(5), y float(5), d float(5) , v float(5), onfield bool, gameid_gsis int, teamid int, playerid_gsis char(10), primary key(time) );
this creates needed table, need fill entries such as:
data, time, x, y, d, v, onfeild, gameid, teamid, playerid_gsis 2015-11-15 ,17:56:45.300 , 93.32, 8.6, 4.57, 0.45 , true, 2015111500 , 5110 , 22-0026189 2015-11-15 ,17:56:45.400 , 93.77, 8.48, 4.55, 0.47 , true, 2015111500 , 5110 , 02-0022289 2015-11-15 ,17:56:45.500 , 94.23, 8.36, 4.53, 0.47 , true, 2015111500 , 5110 , 03-0026179 2015-11-15 ,17:56:45.600 , 94.67, 8.23, 4.51, 0.46 , true, 2015111500 , 5110 , 30-0026180
clearly time not duplicate, when trying fill csv table to data base:
load data infile "/positionaldatangs_2.csv" table positionaldatangs columns terminated ',' lines terminated '\n' ignore 1 lines;
i error: error 1062 (23000): duplicate entry '17:56:45.300' key 'primary'
this mysql 5.6.28 should able handle time fractions of second. thanks!
i can't reproduce problem. in file positionaldatangs_2.csv
there no duplicate values?
test:
mysql> select version(); +-------------------------+ | version() | +-------------------------+ | 5.6.28 | +-------------------------+ 1 row in set (0.00 sec) mysql> drop table if exists `positionaldatangs`; query ok, 0 rows affected (0.01 sec) mysql> create table `positionaldatangs`( -> `date` date, -> `time` time(3), -> `x` float(5), -> `y` float(5), -> `d` float(5), -> `v` float(5), -> `onfield` bool, -> `gameid_gsis` int, -> `teamid` int, -> `playerid_gsis` char(10), -> primary key(`time`) -> ); query ok, 0 rows affected (0.00 sec) mysql> insert `positionaldatangs` ( -> `date`, -> `time`, -> `x`, -> `y`, -> `d`, -> `v`, -> `onfield`, -> `gameid_gsis`, -> `teamid`, -> `playerid_gsis` -> ) -> values -> ('2015-11-15', '17:56:45.300', 93.32, 8.6, 4.57, 0.45, true, '2015111500', 5110, '22-0026189'), -> ('2015-11-15', '17:56:45.400', 93.77, 8.48, 4.55, 0.47, true, '2015111500', 5110, '02-0022289'), -> ('2015-11-15', '17:56:45.500', 94.23, 8.36, 4.53, 0.47, true, '2015111500', 5110, '03-0026179'), -> ('2015-11-15', '17:56:45.600', 94.67, 8.23, 4.51, 0.46, true, '2015111500', 5110, '30-0026180'); query ok, 4 rows affected (0.00 sec) records: 4 duplicates: 0 warnings: 0 mysql> select -> `date`, -> `time`, -> `x`, -> `y`, -> `d`, -> `v`, -> `onfield`, -> `gameid_gsis`, -> `teamid`, -> `playerid_gsis` -> -> `positionaldatangs`; +------------+--------------+-------+------+------+------+---------+-------------+--------+---------------+ | date | time | x | y | d | v | onfield | gameid_gsis | teamid | playerid_gsis | +------------+--------------+-------+------+------+------+---------+-------------+--------+---------------+ | 2015-11-15 | 17:56:45.300 | 93.32 | 8.6 | 4.57 | 0.45 | 1 | 2015111500 | 5110 | 22-0026189 | | 2015-11-15 | 17:56:45.400 | 93.77 | 8.48 | 4.55 | 0.47 | 1 | 2015111500 | 5110 | 02-0022289 | | 2015-11-15 | 17:56:45.500 | 94.23 | 8.36 | 4.53 | 0.47 | 1 | 2015111500 | 5110 | 03-0026179 | | 2015-11-15 | 17:56:45.600 | 94.67 | 8.23 | 4.51 | 0.46 | 1 | 2015111500 | 5110 | 30-0026180 | +------------+--------------+-------+------+------+------+---------+-------------+--------+---------------+ 4 rows in set (0.00 sec)
update
file: positionaldatangs_2.csv
data,time,x,y,d,v,onfeild,gameid,teamid,playerid_gsis 2015-11-15,17:56:45.300,93.32,8.6,4.57,0.45,true,2015111500,5110,22-0026189 2015-11-15,17:56:45.400,93.77,8.48,4.55,0.47,true,2015111500,5110,02-0022289 2015-11-15,17:56:45.500,94.23,8.36,4.53,0.47,true,2015111500,5110,03-0026179 2015-11-15,17:56:45.600,94.67,8.23,4.51,0.46,true,2015111500,5110,30-0026180
mysql:
mysql> truncate table `positionaldatangs`; query ok, 0 rows affected (0.00 sec) mysql> load data infile '/path/to/file/positionaldatangs_2.csv' -> table `positionaldatangs` -> columns terminated ',' -> lines terminated '\n' -> ignore 1 lines; query ok, 4 rows affected, 4 warnings (0.01 sec) records: 4 deleted: 0 skipped: 0 warnings: 4 mysql> show warnings; +---------+------+---------------------------------------------------------------+ | level | code | message | +---------+------+---------------------------------------------------------------+ | warning | 1366 | incorrect integer value: 'true' column 'onfield' @ row 1 | | warning | 1366 | incorrect integer value: 'true' column 'onfield' @ row 2 | | warning | 1366 | incorrect integer value: 'true' column 'onfield' @ row 3 | | warning | 1366 | incorrect integer value: 'true' column 'onfield' @ row 4 | +---------+------+---------------------------------------------------------------+ mysql> select -> `date`, -> `time`, -> `x`, -> `y`, -> `d`, -> `v`, -> `onfield`, -> `gameid_gsis`, -> `teamid`, -> `playerid_gsis` -> -> `positionaldatangs`; +------------+--------------+-------+------+------+------+---------+-------------+--------+---------------+ | date | time | x | y | d | v | onfield | gameid_gsis | teamid | playerid_gsis | +------------+--------------+-------+------+------+------+---------+-------------+--------+---------------+ | 2015-11-15 | 17:56:45.300 | 93.32 | 8.6 | 4.57 | 0.45 | 0 | 2015111500 | 5110 | 22-0026189 | | 2015-11-15 | 17:56:45.400 | 93.77 | 8.48 | 4.55 | 0.47 | 0 | 2015111500 | 5110 | 02-0022289 | | 2015-11-15 | 17:56:45.500 | 94.23 | 8.36 | 4.53 | 0.47 | 0 | 2015111500 | 5110 | 03-0026179 | | 2015-11-15 | 17:56:45.600 | 94.67 | 8.23 | 4.51 | 0.46 | 0 | 2015111500 | 5110 | 30-0026180 | +------------+--------------+-------+------+------+------+---------+-------------+--------+---------------+ 4 rows in set (0.00 sec)
Comments
Post a Comment