I have a text file, named data.dat. The data doesn't have delimiters, but each column has a fixed width.
I'm trying to upload it to MySQL using:
LOAD DATA LOCAL INFILE 'data.dat' INTO TABLE table
It's my understanding that the default here is fixed-width, based on the length defined in the table structure.
My table looks like:
col1 char(7)
col2 char(10)
col3 char(30)
col4 char(10)
col5 char(30)
col6 char(10)
col7 char(8)
They all have the default collation of "latin1_swedish_ci" (which I didn't set, so I guess that's the default).
The problem I'm having is that when I import the data, col1 comes in right but the rest of the data is ignored. So col2 - col7 are all empty.
Am I wrong about the default being fixed width? If so, how do I make it load correctly?
In researching, I found this alternative:
LOAD DATA LOCAL INFILE 'data.dat' INTO TABLE table
(@var1)
SET
col1 = SUBSTR(@var1, 1, 7),
col2 = SUBSTR(@var1, 8, 10),
col3 = SUBSTR(@var1, 18, 30),
col4 = SUBSTR(@var1, 48, 10),
col5 = SUBSTR(@var1, 58, 30),
col6 = SUBSTR(@var1, 88, 10),
col7 = SUBSTR(@var1, 98, 8);
But in that, I have no idea what @var1 represents? Or is it just a placeholder that I should leave named as @var1?