When to use CSV storage engine for MySQL?

前提是你 提交于 2019-12-05 21:46:18

I seldom use the CSV storage engine. One scenario I have found it useful, however, is for bulk data imports.

  1. Create a table with columns matching my input CSV file.
  2. Outside of mysql, just using a shell prompt, mv the CSV file into the MySQL data dictionary, overwriting the .csv file that belongs to my table I just created.
  3. ALTER TABLE mytable ENGINE=InnoDB

Voilà! One-step import of a huge CSV data file using DDL instead of INSERT or LOAD DATA.

Granted, it's less flexible than INSERT or LOAD DATA, because you can't do NULLs or custom overrides of individual columns, or any "replace" or "ignore" features for handling duplicate values. But if you have an input file that is exactly what you want to import, it could make the import very easy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!