How to Write Your First SQL Select Statement in DBeaver

If you’re new to DBeaver, the SQL Editor is where you’ll write your first SQL select statement. This tutorial walks you through creating a new SQL script, writing a simple SELECT query, and viewing your results, all the basics you need to start working with your database.

How to Create SQL Scripts in DBeaver

With the SQL Editor, you can write and execute scripts, save them as files, and reuse them later. To create a new SQL script or to open an existing one, go to the main menu, click SQL Editor, and select an appropriate option. Here you can also open a recent script.

If you have not selected a specific database, a window will appear that will prompt you to choose a connection.

Many of our users prefer to write scripts in the SQL console, which is a feature DBeaver provides. As scripts written this way are not saved in a file format, in some cases the console is faster and more convenient to use.

The SQL button above the Navigation tree allows you to open SQL scripts, as well as change the default command. For example, you can set up quick opening of the console by clicking on this button.

You can use the SQL Editor for executing full scripts and single queries like SELECT, INSERT, DROP, etc. By default, each new script will open in a new tab, which you can change if you want.


Writing Your First SQL Select Statement

Let’s try to write and execute a couple of simple queries to demonstrate the essential features of the SQL editor. We will use our test database. Working with any of your tables will be the same.

Imagine that you own a shop and store your customer data in a database. You can use queries to quickly analyze purchase statistics. Let’s execute a Select query to show only those Billing addresses for which the Total value is greater than 10. Enter the query, then click on the Execute button. As a result set, you will see a table in the Data Editor.

You can perform many operations on this table. Don’t forget to read our article about the Data Editor.

You will not see the result in the table form for some query types. For example, if you run the insert query, you’ll see a message about the changes you’ve made or an error message.

Let’s check that our query worked and the row was added to the table. To do this, we need to execute a Select query.

As you can see in the result set, there is a new row in the table with the correct data.

In the same way, you can write and execute various queries and work with different SQL scripts by using the SQL Editor.
To learn more about all the features of this tool, check out our Wiki.


SQL Editor Highlighting and Settings

The SQL editor highlights keywords, which is especially useful for large scripts.

Different databases have different sets of reserved keywords and system functions, so highlighting depends on the database associated with the script.

You can change the editor settings according to your personal needs. To do this, click on the gear icon and go to Editors -> SQL Editor. Here you can change the formatting, script processing settings, and more. For example, here you can change how the code completion works, which is one of DBeaver’s most useful and convenient features.

The SQL editor also has a right-click context menu with many options. For example, to convert a case, you need to select a part of the script, right-click, and go to Format -> Upper case or Format -> Lower case. This feature can be useful when dealing with case-sensitive databases.

We hope this tutorial was helpful for you. You can find more tutorials on SQL scripting in DBeaver on our blog.


FAQ about SQL SELECT statements in DBeaver

What are the fastest shortcuts to create SQL scripts?

You can create a new SQL script quickly by pressing CTRL+] (or CMD+] on macOS) after selecting your connection in the navigation tree. Other helpful shortcuts include CTRL+Shift+F to format your script and Alt+6 to switch between the SQL Editor and Results panel. For more time-saving hotkeys, see our guide to top DBeaver shortcuts for creating new SQL scripts.

Can I reuse existing SQL scripts in DBeaver?

Yes, DBeaver makes it easy to import and reuse SQL files. You can open files directly from the main menu, import script content into a new editor tab, or link entire folders of SQL files to your project. This is especially useful when migrating from other database tools or sharing scripts with teammates. Learn all three methods in our article on how to import SQL in DBeaver.

Can AI help me write a SQL select statement?

Yes, DBeaver includes AI features that can generate SQL queries from natural language. Instead of writing the full syntax yourself, you can describe what data you need (like “show all customers with orders over $100”) and the AI creates the corresponding SQL select statement. Your database context is provided automatically, so the generated queries match your actual schema. Explore all the options in our overview of AI for SQL coding in DBeaver.