"Kommaet" kan forårsage problemer. Bruger du load data infile til dette?
Forudsat tabeldefinition:
CREATE TABLE `t` (
`code` varchar(255) DEFAULT NULL,
`state` char(2) DEFAULT NULL,
`city` char(3) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`year` int(11) DEFAULT NULL,
`pop1` int(11) DEFAULT NULL,
`pop2` int(11) DEFAULT NULL,
`diff` int(11) DEFAULT NULL,
`ratio` float DEFAULT NULL
)
Følgende ville importere filen:
load data local infile "test.txt"
into table t
columns terminated by '\t'
optionally enclosed by '"'
(code, state, city, name, year, @var1, @var2, diff, ratio)
set pop1=replace(@var1,",", ""),
pop2=replace(@var2, ",", "");
ville indsætte følgende række:
code: CN010010 state: 01 city: 001 name: Autauga County, AL year: 2005 pop1: 23831 pop2: 23061 diff: 770 ratio: 3.2