Did you know that you can work with SQL scripts almost without using your mouse? In this article, we are going to talk about some useful shortcuts for SQL Editor that would be helpful in working with existing scripts.
Open the script
With DBeaver, you can either write a script from scratch or use an existing one. Moreover, this is available not only for scripts that have been created and saved through our app. For example, if one of your colleagues shared an SQL file with you, you can upload it from your system. This can be done in two ways: from the context menu of the SQL Editor or using the shortcut Ctrl+Alt+Shift+O.
You can get back to working with a recent script using the shortcut Ctrl+Enter. It opens the last script for the connection which you would have selected in the tree. If you have not previously selected any connection, you will see a window with a choice of the data source.
Please note that all of your editors must be closed to use this shortcut.
The script and single query execution
To execute a statement or a full script, you can use the corresponding buttons in the left toolbar of the SQL Editor. But here, the same shortcut Ctrl+Enter comes to your aid, which you can run the selected query through. If you want to execute the full script, press Alt+X.
Quick switching between queries
Now you know how to run a query using the keyboard. But to switch between them, you also do not need to use the mouse. Instead, you can use shortcuts Alt+Down and Alt+Up.
Copy and paste queries
Sometimes you might want to copy and paste one or several queries. To do this, just select them and press Ctrl+Alt+Down (Cmd+Option+Down on macOS). The selection will automatically be transferred to the copy you have made.
Hide and show the results panel
If you want to scroll down conveniently and view your script in the editor after the query execution, you can hide the results panel and then show it again using the shortcut Ctrl+6.
What else can you do with shortcuts?
We have shared convenient shortcuts for working with existing SQL scripts. But we can also suggest a few cool shortcuts to help write new scripts. Don’t miss our next article where you can learn more about them.