0

I am trying to insert into sql from a csv file.

LOAD DATA INFILE "file.csv"
INTO TABLE table_name
FIELDS TERMINATED BY " "
LINES TERMINATED BY "\n"
(
    id,
    name
);

My csv has the format:

123 Bob

or:

124

I want to have a default name for the case where the name isn't present. I set up the column to have a default value:

ALTER TABLE table_name
ADD COLUMN name
varchar(255)
DEFAULT 'jerry';

However, when I run the insert, it is just putting empty values into the name column

Jimmy Pitts
  • 2,292
  • 3
  • 20
  • 24

1 Answers1

0

Duplicate o MySQL load NULL values from CSV data.

You have to use \N to get the null values in

Community
  • 1
  • 1
georgecj11
  • 1,600
  • 15
  • 22