What's the right syntax to insert a value inside a column of type bit(1)
in `MySQL'?
My column definition is:
payed bit(1) NOT NULL
I'm loading the data from a csv
where the data is saved as 0
or 1
.
I've tried to do the insert using:
b'value' or 0bvalue (example b'1' or 0b1)
As indicated from the manual.
But I keep getting this error:
Warning | 1264 | Out of range value for column 'payed' at row 1
What's the right way to insert a bit
value?
I'm not doing the insert manually but I'm loading the data from a csv
(using load data infile
) in which the data for the column is 0
or 1
.
This is my load
query, I've renamed the fields for privacy questions, there's no error in that definition:
load data local infile 'input_data.csv' into table table
fields terminated by ',' lines terminated by '\n'
(id, year, field1, @date2, @date1, field2, field3, field4, field5, field6, payed, field8, field9, field10, field11, project_id)
set
date1 = str_to_date(@date1, '%a %b %d %x:%x:%x UTC %Y'),
date2 = str_to_date(@date2, '%a %b %d %x:%x:%x UTC %Y');
show warnings;
This is an example row of my CSV:
200014,2013,0.0,Wed Feb 09 00:00:00 UTC 2014,Thu Feb 28 00:00:00 UTC 2013,2500.0,21,Business,0,,0,40.0,0,PROSPECT,1,200013
Update:
I didn't find a solution with the bit
, so I've changed the column data type from bit
to tinyint
to make it work.