On MS SQL, I can do bulk insert using the sql command below:
BULK INSERT myDatabase.MyTable FROM 'C:\MyTextFile.txt' WITH FIELDTERMINATOR = ','
Now I want to do the same on MySQL but I can't seem to figure out how this works and what query to use.
The INSERT statement in MySQL also supports the use of VALUES syntax to insert multiple rows as a bulk insert statement. To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas.
MySQL INSERT multiple rows statement In this syntax: First, specify the name of table that you want to insert after the INSERT INTO keywords. Second, specify a comma-separated column list inside parentheses after the table name. Third, specify a comma-separated list of row data in the VALUES clause.
Or you can go to Edit -> Preferences -> SQL Editor -> SQL Execution and set the limit on Limit Rows Count.
BulkInsert doesn't create a transaction by default. If you want to save multiple lists, you will need to handle the transaction in your code.
In MySQL, the equivalent would be
LOAD DATA INFILE
http://dev.mysql.com/doc/refman/5.1/en/load-data.html
LOAD DATA INFILE 'C:\MyTextFile' INTO TABLE myDatabase.MyTable FIELDS TERMINATED BY ','
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With