简体   繁体   中英

Ignore Column data while importing to MySQL via Command Line

This question may sound like a novice one.

I'm having a data table in Mysql like below (ID is autoincrement)

 ID   NAME   MDATE   QTY

I'm using to load this table from a text file via Command line like

"LOAD LOCAL DATA INFILE....".

It works perfectly. Now in my input text file i've another new column,that i dont want to import.Like below case, i want to exclude the Count column.

Count Name  Date       Qty
1     ABC   1/12/2013  25 
2     ACE   1/12/2013  15 
3     DBC   1/12/2013  12

How do i ignore this column?

You can also discard an input value by assigning it to a user variable and not assigning the variable to a table column:

LOAD DATA INFILE 'file.txt'
INTO TABLE t1 (column1, @dummy, column2, @dummy, column3);

Try checking: http://dev.mysql.com/doc/refman/5.1/en/load-data.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM