Jump to content

Execute multiple statements in one query (for execute *.sql file)


Recommended Posts

also, from mysql manual

 

[pre]

4.9.13 How to Run SQL Commands from a Text File

The mysql client typically is used interactively, like this:

 

shell> mysql database

 

However, it's also possible to put your SQL commands in a file and tell mysql to read its input from that file. To do so, create a text file `text_file' that contains the commands you wish to execute. Then invoke mysql as shown here:

 

shell> mysql database < text_file

 

You can also start your text file with a USE db_name statement. In this case, it is unnecessary to specify the database name on the command line:

 

shell> mysql < text_file

 

If you are already running mysql, you can execute an SQL script file using the source command:

 

mysql> source filename;

 

For more information about batch mode, section 3.5 Using mysql in Batch Mode.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.