0

I'm trying to load up a simple CSV file using this tutorial. My CSV includes the list of nationalities, of which here is a sample:

1,Afghan,2015-10-14 17:56:39

Meanwhile, my table definitions is:

+-------------+--------------+------+-----+-------------------+-----------------------------+
| Field       | Type         | Null | Key | Default           | Extra                       |
+-------------+--------------+------+-----+-------------------+-----------------------------+
| ID          | int(11)      | NO   | PRI | NULL              | auto_increment              |
| Nationality | varchar(255) | NO   | UNI | NULL              |                             |
| Time        | timestamp    | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+-------------+--------------+------+-----+-------------------+-----------------------------+

I'm running the following command:

BULK INSERT meta_nationality FROM '/home/benjamin/Downloads/Nationalities.csv' WITH (fieldterminator = ',', rowterminator ='\n');

This seems to be right, however I get an error message pointing to a syntax issue:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bulk insert...

According to the documentation the syntax error refers to the use of a reserved word, but I wouldn't know which one it is in this case.

Could you help me figure out my way through this? Thanks.

1
  • 1
    The tutorial you're following is for SQL Server, not MySQL. Syntax differs significantly between the two. Commented Oct 15, 2015 at 15:49

3 Answers 3

1

Since you're using MySQL you'll want to use a different syntax. You should be aware that the tutorial you're following is for MSSQL.

LOAD DATA INFILE "/home/benjamin/Downloads/Nationalities.csv"
INTO TABLE meta_nationality
COLUMNS TERMINATED BY ','
LINES TERMINATED BY '\n'
Sign up to request clarification or add additional context in comments.

Comments

0

BULK INSERT isn't a command.

You were probably looking for LOAD DATA INFILE _____ INTO TABLE _____

Comments

0

Please refer MySQL tutorials instead of SQL server. LOAD DATA INFILE command will help you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.