24

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

Maddy.Shik
  • 6,609
  • 18
  • 69
  • 98

1 Answers1

25

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
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • 3
    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 – Maddy.Shik Oct 27 '10 at 01:41
  • 5
    is it possible to give relative path of script files with respect to file that is contain these commands. – Maddy.Shik Oct 29 '10 at 16:51
  • 19
    The mysql workbench displays error "SOURCE (source) is not valid input at this position". – Pawan Oct 22 '16 at 08:58