Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Workbench Import NULL from CSV

I can't for the life of me make MySQL Workbench import NULL for blank cells in a CSV.

I've tried:

  • blank
  • NULL
  • \N
  • Each with and without ""

How the does one signify a cell is 'null' inside a CSV file I want to import into MySQL via Workbench?

like image 563
Trees4theForest Avatar asked Jul 15 '18 15:07

Trees4theForest


2 Answers

Since MySQL Workbench version 8.0.16 (released on 04/25/2019) there has been an additional option for uploading .csv file -- "null and NULL word as SQL keyword". When selecting this option as YES, the NULL expression without quotes in .csv file (,NULL, rather than ,"NULL",) will work for this purpose.

like image 100
Zq.Z Avatar answered Oct 21 '22 07:10

Zq.Z


If you were trying to import a CSV into the model for creating insert scripts (where you won't get the same options described in the other answers), try the following:

\func NULL

You can also use this syntax to call functions like the following to insert the current date time when you forward engineer the model to the database:

\func CURRENT_TIMESTAMP
like image 37
Nico M Avatar answered Oct 21 '22 08:10

Nico M