MySQL Forums
Forum List  »  Newbie

LOAD DATA INFILE not accepting my FIELDS TERMINATED BY
Posted by: Paul Pikowsky
Date: April 20, 2010 12:09PM

I am trying to load a file from a Notepad .txt file into a table.

Here is a sample of the data,

VARCHAR_Field_1**VARCHAR_Field_2**VARCHAR_Field_3**VARCHAR_Field_4

Here is my SQL,

LOAD DATA INFILE 'C:\\Documents and Settings\\MyUser\\My Documents\\etc\\MyNotepadTextFile.txt'
INTO TABLE My_Table
FIELDS TERMINATED BY '**'
(Field_1, Field_2, Field_3, Field_4)

I first got an error "ERROR 1406 (22001): Data too long for column "Field_1' at row 1" which suggested to me that the field terminators were not being observed and I stretched the VARCHAR column to allow huge fields and tried again and got the second error confirming my suspicions, "ERROR 12661 (01000): Row 1 doesn't contain data for all columns"

What should I be using for my LOAD DATA INFILE command to get this data in?

Here is the table I am using:

DROP TABLE IF EXISTS `My_Table`;
CREATE TABLE  `My_Table` (
  `TNID` int(10) unsigned NOT NULL auto_increment,
  `Field_1` varchar(200) NOT NULL default '',
  `Field_2` varchar(45) NOT NULL default '',
  `Field_3` varchar(45) NOT NULL default '',
  `Field_4` varchar(400) NOT NULL default '',
  PRIMARY KEY  (`TNID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;



Edited 3 time(s). Last edit at 04/20/2010 01:13PM by Paul Pikowsky.

Options: ReplyQuote


Subject
Written By
Posted
LOAD DATA INFILE not accepting my FIELDS TERMINATED BY
April 20, 2010 12:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.