Mysql: Loading data from file

Loading Data into Tables from Text Files.

Assume you have the following table.

            CREATE TABLE loadtest (
                pkey int(11) NOT NULL auto_increment,
                name varchar(20),
                exam int,
                score int,
                timeEnter timestamp(14),
                PRIMARY KEY  (pkey)

And you have the following formatted text file as shown below with the unix "tail" command:

          $ tail /tmp/out.txt

    NOTE: loadtest contains the "pkey" and "timeEnter" fields which are not
    present in the "/tmp/out.txt" file. Therefore, to successfully load
    the specific fields issue the following:

         mysql> load data infile '/tmp/out.txt' into table loadtest
                  fields terminated by ',' (name,exam,score);