3

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...

1
  • 1
    cat script1.sql script2.sql script2.sql | mysql Commented Jul 3, 2009 at 20:18

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

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.