Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run script from within Mysql workbench?

I have a SQL script to distribute to others to run from a MySQL IDE, not from a MySQL command prompt.

I want the user to load the script into a window of workbench (or another IDE like sqlyog) and just run the script, which inserts records based on variables, for example:

SELECT value FROM mytable WHERE key = "mykey" into @columnid;

INSERT INTO mytable (col2,col3) VALUES (
@columnid,
'testvalue'
)

We all have MySQL Workbench installed but I don't see a way to do this from workbench.

Is there a way to run a script (that is in an editor window) from workbench (or any other MySQL IDE) the way you can run scripts from other database IDE's like Toad or SQL Server Management Studo?

like image 476
draca Avatar asked Apr 09 '15 18:04

draca


Video Answer


2 Answers

You just need to go to the File option and then click Open SQL Script.

You can refer: SQL Query Window Toolbar and a small video

like image 45
Rahul Tripathi Avatar answered Sep 22 '22 08:09

Rahul Tripathi


There are two different methods:

  1. File -> Open SQL Script: This simply loads the file contents into a new SQL query tab in the SQL editor. From here, execute the query exactly like you would if you typed it in.

  2. File -> Run SQL Script: This opens the SQL script in its own "Run SQL Script" wizard that includes a [Run] button to execute the query. This only displays part of the query, but does allow the user to override the selected schema and character set. Note: This feature was added in Workbench 6.2.

I suspect you want the simpler "Run SQL Script".

like image 164
Philip Olson Avatar answered Sep 20 '22 08:09

Philip Olson