25

Suppose I have wrote script Table_ABC.sql which creates table ABC. I have created many such scripts for each of required tables. Now i want to write a script that call all of these script files in a sequence so basically I want another script file createTables.sql. Mysql provides option to execute a script file from "mysql" shell application but could find some command like exec c:/myscripts/mytable.sql. Please tell me if there is any command that can be written in sql script itself to call other one in latest mysql versions or alternative for same.

Thanks

2
  • I assume there is some reason why you can't just put all your SQL files into one and run that? Commented Oct 27, 2010 at 1:12
  • 3
    I am creating one script for each table better structuring and better management. Commented Oct 27, 2010 at 1:15

1 Answer 1

26

You can use source command. So your script will be something like:

use your_db;
source script/s1.sql;
source script/s2.sql;
-- so on, so forth
Sign up to request clarification or add additional context in comments.

4 Comments

I had already gone through this page. source command run on mysql application but i want to run it on mysql workbench's query analyzer tool. Thanks
is it possible to give relative path of script files with respect to file that is contain these commands.
The mysql workbench displays error "SOURCE (source) is not valid input at this position".
This is the same error as in this question stackoverflow.com/questions/45227599/…

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.