0

I have data as follows in my csv:

ID, NAME, fav_digit

1 abc 2

2 xyz

3 pqr 7

Now, I have created the table in the MySQL table using the data types Int, Varchar(7), Int respectively.
But the table has populated 0 in the row where id = 2 This means that the fav_diigit is unintentionally representing 0, but in reality, the data is not present. Is it that we can't populate NULL in an INT column?

I need to indicate that the cell is empty rather than a digit like 0

I was expecting NULL value in second row.BTW, I have connected my file from excel to MySQL using this command/query:

LOAD DATA LOCAL INFILE 'C:\Users\path\to\file\file.csv'
INTO TABLE file_data
FIELDS TERMINATED BY ','
    ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(id, Name, fav_digit);
2
  • 2
    Of course you CAN store NULL in an int column. Whether LOAD DATA does that or not is the question. Did you set DEFAULT NULL for that column? Commented Jun 26, 2024 at 5:10
  • I did set the DEFAULT NULL but seems the issue persists.I feel it is stemming from Infile.. command. Commented Jun 26, 2024 at 7:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.