fishyninja1 fishyninja1 - 3 months ago 13
MySQL Question

What is the correct syntax for the SOURCE command in SQL

In codeAnywhere I'm trying to run pre written script files to create a table. When using codeAnywhere one must import the file to the shell for the code first, as I have done. However I have been unable to use the

command to run these files. I have currently attempted this syntax:

USE exams SOURCE students.txt;

What is the correct syntax here? Do I need to name the database in the syntax?
Are there other commands which run text files containing code?

EDIT: I tried using this syntax, to the following result:

ERROR: Failed to open file 'exams(question5.txt)', error: 2


On the shell you can use the following command to execute the queries from a text file:

mysql db_name < text_file

Hint: If the USE command (with correct database name) is specified on the textfile you don't need to specify the database. The SOURCE command is not available on MySQL instead you need the <.

You can find more information about executing queries from text files here: