Execute statement by shortcut in MySQLWorkbench
MysqlMysql WorkbenchMysql Problem Overview
How can I execute any statement in MySQLWorkbench using shortcut? Now I have to press button (yellow lightning). Of course I have read this in the documentation: Table 14.6 - query menu (Table 14.6 - query menu) but I don't know what does mean Modifier+Return
?
As we can read Modifier
is Ctrl
(in Windows) but what is Return
?
Mysql Solutions
Solution 1 - Mysql
Return
= Enter
key. So Ctrl + Enter
key should execute.
Solution 2 - Mysql
MySQL Workbench 6.3
Default key mapping
- Execute (All or Selection) -> Ctrl+Shift+Enter
- Execute Current Statement -> Ctrl+Enter
Change the default mapping
Open:
C:\Program Files\MySQL\MySQL Workbench 6.3 CE\data\main_menu.xml
If you search for Execute (All or Selection) and for Execute Current Statement, you'll also identify (based on what you see in the screenshot above) the meaning of Modifier and Return:
- Modifier = Ctrl
- Return = Enter
Here you can change the default mappings. Being familiar with other tools like SQuirreL SQL and pgAdmin, I always prefer to run only the selected query using Ctrl+Enter or F5, so I change the following in the main_menu.xml:
- To run the selected query using Ctrl+Enter:
<value type="object" struct-name="app.MenuItem" id="com.mysql.wb.menu.query.exec">
<link type="object" key="owner" struct-name="app.MenuItem">com.mysql.wb.menu.query</link>
<value type="string" key="caption">Execute (All or Selection)</value>
<value type="string" key="name">query.execute</value>
<value type="string" key="command">builtin:query.execute</value>
<value type="string" key="itemType">action</value>
<value type="string" key="shortcut">Modifier+Return</value>
</value>
...
<value type="object" struct-name="app.MenuItem" id="com.mysql.wb.menu.query.execute_current_statementwin">
<link type="object" key="owner" struct-name="app.MenuItem">com.mysql.wb.menu.query</link>
<value type="string" key="caption">Execute Current Statement</value>
<value type="string" key="name">query.execute_current_statement</value>
<value type="string" key="command">builtin:query.execute_current_statement</value>
<value type="string" key="itemType">action</value>
<value type="string" key="shortcut">Modifier+Shift+Return</value>
<value type="string" key="platform">windows</value>
</value>
2. Run the selected query using F5:
<value type="object" struct-name="app.MenuItem" id="com.mysql.wb.menu.query.exec">
<link type="object" key="owner" struct-name="app.MenuItem">com.mysql.wb.menu.query</link>
<value type="string" key="caption">Execute (All or Selection)</value>
<value type="string" key="name">query.execute</value>
<value type="string" key="command">builtin:query.execute</value>
<value type="string" key="itemType">action</value>
<value type="string" key="shortcut">F5</value>
</value>
Save the file and restart MySQL Workbench to see the changes.
Solution 3 - Mysql
Executing statement at cursor
Ctrl + Enter (for Windows)
Executing all statements within selection
Ctrl + Shift + Enter Key (for Windows)
Solution 4 - Mysql
For Mac:
Command + Return
should work.
PS. this executes whatever you have in the query editor until it finds ';'
.
Solution 5 - Mysql
Solution 6 - Mysql
Press Ctrl + Enter
to execute
you can find full list of shortcodes on following link
https://dev.mysql.com/doc/workbench/en/wb-keys.html
Solution 7 - Mysql
If you want to customize the selection so that both will run with a shortcut
1.) the partial selection or run selected to curser, then you need to update:
the shortcut element in the node com.mysql.wb.menu.query.exec in the main_menu.xml file.
how I have mine set:
<value type="object" struct-name="app.MenuItem" id="com.mysql.wb.menu.query.exec">
<link type="object" key="owner" struct-name="app.MenuItem">com.mysql.wb.menu.query</link>
<value type="string" key="accessibilityName">Execute All or Selection</value>
<value type="string" key="caption">Execute (All or Selection)</value>
<value type="string" key="name">query.execute</value>
<value type="string" key="command">builtin:query.execute</value>
<value type="string" key="itemType">action</value>
<value type="string" key="shortcut">F6</value>
</value>
2.) for updating the execute the entire page (regardless or what is selected), then change:
the element shortcut in either: com.mysql.wb.menu.query.execute_current_statementwin (windows) com.mysql.wb.menu.query.execute_current_statement (non-windows)
how I have mine:
<value type="object" struct-name="app.MenuItem" id="com.mysql.wb.menu.query.execute_current_statementwin">
<link type="object" key="owner" struct-name="app.MenuItem">com.mysql.wb.menu.query</link>
<value type="string" key="accessibilityName">Execute Current Statement</value>
<value type="string" key="caption">Execute Current Statement</value>
<value type="string" key="name">query.execute_current_statement</value>
<value type="string" key="command">builtin:query.execute_current_statement</value>
<value type="string" key="itemType">action</value>
<value type="string" key="shortcut">F5</value>
<value type="string" key="platform">windows</value>
</value>
..unfortunately I was not able to configure this so that F5 would work for both a partial selection and the entire page, so I chose to set one of them to F6. Hope this helps someone out )