views:

84

answers:

2

Is it possible to INCLUDE other mysql scripts in a composite script? Ideally I do not want to create a stored procedure for the included scripts... For larger projects I would like to maintain several smaller scripts hierarchically and then compose them as required... But for now, I'd be happy to just learn how to include other scripts...

A: 

MySQL scripts are just a list of commands, to be run in order against the database server. SQL is not a scripting language by any means, so it doesn't behave like one. The only way to "include" other scripts is to concatenate them together when you kick off the script load command.

Eric
+2  A: 

source is a builtin command you can use in the MySQL client tool (which is what you're using to execute the SQL script):

mysql> source otherfile.sql

If you're executing SQL in a stored procedure or with an API, you should know that MySQL client builtins work only in the MySQL client.

Bill Karwin
Excellent! This is exactly what I was looking for.. Thanks..
badkya