Home > database >  With the LOAD DATA import DATA, the first character always be truncated
With the LOAD DATA import DATA, the first character always be truncated

Time:10-19

Novice,
Need to use the load data import company data, first as a date, format for characters such as "201507",
I under table definition first as a string of six, and such as s_month varchar (6), import the data statement
The Load Data InFile 'D:/1/2015-821. The CSV Into Table ` ori_2015_821 ` fields terminated by', 'lines terminated by' \ n ';

System error: 1265 Data truncated for column 's_month' at row 1

Query tables are finding the first line of the first data is truncated to "20150"

When building table is modified to varchar (7), then the system is not an error, but using the group by statement, summary contains two 201507

Please everyone a great god take on the road, help to solve this problem

CodePudding user response:

Varchar (6) can save six characters, you can check whether there is a space not found, as to collect duplicate, should be the data transfer or SQL statement out of the question

CodePudding user response:


Don't have specific data, the estimate is the data format is not standard, how many lines you see the error, open the data file, see if there is a problem

CodePudding user response:

reference 1st floor wangjian0228 response:
varchar (6) can save six characters, you can check whether there is a space not found, as to collect duplicate, should be the data transfer or SQL statements wrong


201507821301949030, kunming, 4201, 507258370, 34.00, 270.33, 270.33, 233.12, 2.66, 37.21, 0.00, 0.00, 36763.67

Spaces has replaced the 201507 should be six characters, the first record is the CSV file will be truncated to 20150, the other is normal

CodePudding user response:

refer to the second floor yupeigu response:
have specific data, estimation is the data format is not standard, and see how many you do quote error, open the data file, see if there are problems


201507821301949030, kunming, 4201, 507258370, 34.00, 270.33, 270.33, 233.12, 2.66, 37.21, 0.00, 0.00, 36763.67
The following lines like

Spaces has replaced the 201507 should be six characters, the first record is the CSV file will be truncated to 20150, the other is normal

CodePudding user response:

In addition to a stupid way to put the third field (words) in the first, won't appear this problem, the embarrassment

CodePudding user response:

Check your text file character set, the estimate is UTF format, save as ASCII format,

CodePudding user response:

It is ok to remove the last \ n

CodePudding user response:

Why don't you look at the date of the front have hidden small Spaces?
  • Related