Loading CSV files into MySQL Workbench

后端 未结 6 699
旧巷少年郎
旧巷少年郎 2021-02-12 16:10

I have a lot of excel/ CSV files that I need to load into my db in MySQL Workbench (I\'m on Mac OS X). I\'ve searched around for a good walk-through or tutorial, but I haven\'t

6条回答
  •  温柔的废话
    2021-02-12 16:50

    Or you could use Excel to generate a lot of LOAD DATA INFILE statements using a list of files to load.

    Say, you could:

    1. place the names of files in A column of Excel

    2. place a formula like this in B1 cell:

      ="LOAD DATA LOCAL INFILE 'path/"&A1&"' INTO TABLE tablename FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';"

    3. copy & paste B1 cell in B column cells where needed.

    So, you would have LOAD DATA statemens in B column of Excel and could just copy&paste them into mysql command line.

    Maybe it would not be too convinient to power user of scripting, but could make sense for strong user of MS Excel.

提交回复
热议问题