How to import CSV file into MySQL using SQuirreL

I am using SQuirreL SQL and I want to import a CSV file into MySQL. Tell us how to do it.


source to share

2 answers

According to importing-data-from-a-file-like-csv you should right-click on the table you want to import into and in the context menu you should see a menu item called "Import File" where you select your CSV file.

From F1 -> Help -> Data Import Plugin you should get some help about this.



If you need to create a table from .CSV

My case is a little different in that I have a table exported to .CSV and I need to create and import the table from that file.

1. Get column definitions

and. You have access to the original source

If you have exported CSV from another database yourself, you can also go back to that database and get a "table creation script" from there (object panel -> right click on the table in question -> Scripts -> Create Desktop Script).

In the same case, if you can contact the creator of the .CSV: you can request a script to create the table.

b. You just have a .CSV

Connect to .CSV as a database from SQuirreL (you can use hxtt , csvjdbc, or cdata ) and you can get the Create table script.

But so (well, I tried csvjdbc), you just get all the columns as varchar(max)

you will have to edit them to your liking. For 200+ columns, this can be a little painful. On the other hand, you get the data inside the DB, and then you can apply your SQL skill and convert the data to another table with the correct column definitions.

2. Create a table in your destination schema

It's just a DB and Schema connection where you pass the table and run the Create table script there. You will get an empty table.

3. Import data

Object pane -> right click on the table you just created -> Import file

Then follow the wizard.



All Articles