I am trying to import a CSV file into a MySQL 5.1 database.
The script for creating the table is:
CREATE TABLE `session_hdr` (
`id` bigint(20) unsigned NOT NULL,
`type` smallint(5) unsigned NOT NULL,
`session_start_time` decimal(20,8) unsigned DEFAULT NULL,
`session_end_time` decimal(20,8) unsigned DEFAULT NULL,
`session_last_update_time` decimal(20,8) unsigned DEFAULT NULL,
`session_flag` tinyint(3) unsigned DEFAULT NULL,
`version` tinyint(3) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$
This is the data I am tyring to import into the session_hdr table:
0X10004299300,1,7,1324542626.182691780,0.0,1324542627.76399180,1,3
0X1000429BF00,1,7,1324542656.188777040,0.0,1324542657.136454760,1,3
0X1000429CB00,1,7,1324542663.269024060,0.0,1324542663.292035400,1,3
0X1000429F200,1,7,1324542686.177864720,0.0,1324542687.45881600,1,3
0X100042A4000,1,7,1324542716.178234960,0.0,1324542717.645671220,1,3
0X100042A6800,1,7,1324542746.173958660,0.0,1324542747.66159900,1,3
....
The command I am using is to import is:
mysqlimport --ignore-lines=1 -c id,type,session_start_time,session_end_time,session_last_update_time,session_flag,version databaseName1 session_hdr.csv
When I execute the command I reveive the following message:
mysqlimport: Error: 1265, Data truncated for column 'id' at row 1, when using table: session_hdr
Does anyone see why the above command would be throwing that error?
In your data, the first colmn’s value do not conform to an int type, which can only contain numbers. You will need to convert the values from hex to int before importing.