"Komma" kan orsaka problem. Använder du load data infile för detta?
Förutsatt tabelldefinition:
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öljande skulle importera 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, ",", "");
skulle infoga följande rad:
code: CN010010 state: 01 city: 001 name: Autauga County, AL year: 2005 pop1: 23831 pop2: 23061 diff: 770 ratio: 3.2