How to run multiple sql statements at once from the command line
By liviu - Posted on June 8th, 2009
Tagged:
In case you have to work from the command line (ssh?) and you need to run a lot of queries, instead of just running them one by one you can put your sql statements (inserts, updates, queries or whatever) and use:
shell> mysql db_name < text_file
If you have "use db_name" as your first line in your text_file you can just youse
shell> mysql < text_file
If you are in mysql you can use:
mysql> source file_name
You can find this in the mysql manual at the Executing SQL Statements from a Text File chapter.
Bookmark/Search this post with:
- liviu's blog
- Login or register to post comments
Delicious
Digg
StumbleUpon
Propeller
Reddit
Magnoliacom
Newsvine
Furl
Facebook
Google
Yahoo
Technorati
Icerocket