Skip to main content
April 2, 2026Dan Rodney/7 min read

Getting Started & Your First SQL Query

Master SQL fundamentals with hands-on database exploration

Learning Approach

This tutorial uses a demonstration-first approach followed by hands-on exercises. You'll see the concepts explained, then practice them yourself through step-by-step exercises for better retention.

Database Structure Overview

Server Connection

Your database connection represents a server that can contain multiple databases. Think of it as the top-level container for all your data resources.

Database and Schemas

Within each server, databases contain schemas which group related tables together. The 'public' schema is commonly used for main application tables.

Tables and Data

Tables store the actual data with columns defining the type of information. Visual indicators show whether data is numeric, text, or time-based.

Exploring Database Structure

1

Connect to Database Server

Establish connection to your database server. The connection name often reflects the primary database you're connecting to.

2

Navigate Schema Hierarchy

Expand the database to view schemas, then explore the 'public' schema to see available tables and their relationships.

3

Examine Table Structure

Click on table names to view columns and their data types. Icons indicate numeric (123), text (A-Z), and timestamp (clock) data.

4

Preview Actual Data

Double-click tables to open data tabs and examine real records to understand the content and format of stored information.

Sample Database Tables

Users
8
Orders
6
Products
5
Employees
4
Departments
3
Understanding Data Types

VARCHAR(2) means variable-length text with maximum 2 characters, perfect for state abbreviations like 'NY' or 'CA'. VARCHAR(255) allows much longer text fields like addresses or descriptions.

GUI vs SQL Code Approach

Pros
SQL code provides much more control over data queries
Enables complex filtering and data manipulation
Reusable and shareable query scripts
Industry standard for database interactions
Supports advanced operations not available in GUI
Cons
Steeper learning curve compared to point-and-click interface
Requires understanding of SQL syntax and structure
More prone to syntax errors for beginners

Writing Your First SQL Query

1

Create SQL Script

Open a new SQL editor to create a text file where you can write and execute your database queries.

2

Write SELECT Statement

Use 'SELECT * FROM tablename;' syntax to retrieve all columns from a specified table. The asterisk represents all columns.

3

Execute Query

Click the play button or use keyboard shortcuts to run your selected query and view results in the output panel.

SQL Execution Behavior

Unlike most programming languages that run entire files, SQL editors execute only selected queries. Click on a query to select it, or highlight multiple queries to run them together.

Query Selection Methods

FeatureSingle QueryMultiple Queries
Selection MethodClick anywhere on queryHighlight all desired code
Execution ResultRuns one query onlyRuns all selected queries
Output FormatSingle result tabMultiple result tabs
Use CaseTesting individual queriesRunning related query sets
Recommended: Most commonly, you'll run single queries to test and refine your SQL statements.

Essential DBeaver Preferences

0/4
Preference Configuration Location

Access DBeaver preferences through Window > Preferences. SQL formatting options are under Editors > SQL Editor > Formatting, while text editor settings are under Text Editors.

DBeaver Data Loading Behavior

200+
rows loaded initially
200
additional rows per scroll
400
total rows after first scroll
Why Limited Row Loading Matters

DBeaver loads data incrementally to maintain performance. Imagine querying Amazon's order database with billions of records - you only need a sample to understand the data structure and content.

Saving and Managing SQL Files

1

Save Your Query

Use Save As to store your SQL code as a .sql file for future reference and reuse.

2

Organize Files

Create meaningful file names and organize them in project folders for easy retrieval.

3

Reopen Files

Use Open File to browse and reload saved SQL scripts. Remember you need an active database connection to execute them.

SQL files are fundamentally just plain text files because they contain only text code
This makes them lightweight, portable, and easy to version control alongside other project files.

This lesson is a preview from our SQL Course Online (includes software) and SQL Certification Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.

I'll demonstrate the complete database navigation process first, then provide you with a hands-on exercise that reinforces each step. This dual approach—observing followed by practice—accelerates skill acquisition and builds muscle memory for database administration tasks.

Simply watch this initial demonstration without following along. The upcoming step-by-step exercise will guide you through every procedure I'm about to show you, ensuring you master each technique through direct application.

Here in DBeaver, notice my database connection labeled "company_underscore_data." This naming reflects the specific database I connected to during setup. However, it's crucial to understand that this connection represents an entire database server, not just a single database.

To illustrate this concept more clearly, I'll rename this connection by right-clicking and selecting rename. While the exercise won't require this step, I prefer renaming connections to reflect their true nature—imagine this as the "Noble Desktop server" to better understand our architecture.

Database servers host multiple databases, and within our server, "company_data" serves as our primary working database. Inside this database, you'll find schemas—logical groupings that organize related tables for better data management and security.

Expanding the schema structure reveals the "public" schema, though enterprise environments typically contain multiple schemas for different business functions. Our current setup includes one schema containing several interconnected tables that form a complete business data model.

This dataset represents a typical e-commerce company structure: user accounts, order processing systems, product catalogs, and employee management. Users place orders consisting of line items for various products, while employees operate within departmental hierarchies—a common pattern you'll encounter across industries.

When examining unfamiliar data structures, start by exploring individual tables. Expanding the "users" table reveals its column structure, providing immediate insights into the data types and organization. Notice the visual indicators: numbers (1, 2, 3) represent numeric fields, letters (A-Z) indicate text fields, and clock icons denote timestamp data.

These visual cues eliminate guesswork about data types and help you write more effective queries. Double-clicking any table opens a dedicated tab displaying the actual data, allowing you to examine real records and understand the information patterns.

In the users table, you'll see practical business data: names, email addresses, encrypted passwords, and complete address information. Pay attention to data type specifications like "varchar(2)" for state fields—this tells you states are stored as two-character abbreviations (NY, VT) rather than full names (New York, Vermont).

Understanding these specifications prevents common querying mistakes and helps you write more precise database operations. The varchar(255) fields accommodate longer text entries, while timestamp fields track account creation dates—valuable information for user analytics and business intelligence.

To access the data view, double-click any table, then select the "Data" tab from the properties panel. This workflow becomes second nature with practice and provides immediate access to table contents for verification and exploration.

Managing multiple table views efficiently requires good tab organization. Each double-clicked table opens in a separate tab, allowing simultaneous examination of related data structures. Close unused tabs to maintain a clean workspace—you can always reopen them when needed.


Often, examining column structures provides sufficient information about data organization without viewing actual records. The orders table columns—user IDs, order IDs, timestamps, shipping addresses—immediately reveal the order processing workflow and available query options.

While the graphical interface serves well for data exploration, writing SQL code provides far greater control and flexibility. Create a new SQL script to access the code editor, where you'll spend most of your time crafting sophisticated database queries.

The SQL editor environment is highly customizable. Use Command/Ctrl + and - to adjust font sizes for optimal readability during long coding sessions. Proper editor configuration significantly improves productivity and reduces eye strain during complex query development.

Writing your first query follows SQL's intuitive syntax: "SELECT * FROM users;" retrieves all columns from the users table. The asterisk (*) represents a wildcard selecting every available column, while the semicolon terminates the SQL statement—a required convention.

Execute queries using the prominent play button, which runs your code against the connected database and displays results in the lower panel. This immediate feedback loop accelerates learning and helps you understand how SQL transforms into actual data retrieval.

SQL's execution model differs significantly from traditional programming languages. Instead of running entire files sequentially, SQL executes only selected statements. Clicking anywhere within a query selects it for execution, providing precise control over which operations run.

This selective execution proves invaluable when working with complex scripts containing multiple queries. You can test individual statements, compare results from different approaches, and troubleshoot problems without affecting other queries in the same file.

Selecting multiple queries (by highlighting across statements) executes them sequentially, with results appearing in separate tabs. However, most database work involves running single, focused queries rather than batch operations, making the click-to-select approach ideal for daily use.

DBeaver's intelligent selection recognizes statement boundaries automatically—simply clicking within a query selects the entire statement. This smart behavior eliminates the need for precise text highlighting while maintaining full control over execution scope.

By default, DBeaver converts SQL keywords to lowercase, which contradicts industry documentation standards where SQL keywords appear in uppercase. This inconsistency can confuse beginners and creates non-standard code formatting.

Customizing this behavior through preferences ensures your code follows professional conventions. Access preferences through the Window menu, then navigate to Editors > SQL Editor > Formatting. Change the keyword case setting from "default" to "uppercase" for industry-standard formatting.

This preference change affects all future SQL editing, automatically converting keywords like SELECT, FROM, and WHERE to uppercase as you type. Professional database developers universally follow this convention, making your code more readable and maintainable.


Additional workspace optimizations include enabling line numbers and text wrapping. Line numbers facilitate collaboration by providing reference points for discussing code with colleagues, while text wrapping eliminates horizontal scrolling for long queries.

Configure these features under Text Editors in the preferences menu. Enable "Show line numbers" and "Enable word wrap when opening an editor" to create a more professional and comfortable coding environment. These settings apply to all future editor sessions.

Word wrapping proves particularly valuable when working with complex queries containing multiple joins, subqueries, or extensive WHERE clauses. Instead of scrolling horizontally through long lines, wrapped text remains fully visible within the editor window.

Saving SQL scripts preserves your work for future use and creates a personal library of tested queries. Use "Save As" to store scripts in organized directories, with descriptive filenames that indicate the query's purpose or business function.

SQL files are plain text documents containing only your code—no embedded data or proprietary formatting. This simplicity enables version control, easy sharing between team members, and compatibility across different database tools and platforms.

Reopening saved scripts restores your exact code, but remember that execution requires an active database connection. SQL files contain instructions for data retrieval, not the data itself, maintaining security while preserving your analytical work.

Understanding DBeaver's data loading behavior prevents confusion when working with large datasets. The "200+" indicator shows that DBeaver loads only the first 200 rows initially, preventing performance issues when querying tables with millions of records.

This pagination approach mirrors real-world database applications where displaying entire datasets would create unacceptable delays and consume excessive system resources. Instead, DBeaver loads additional data in 200-row increments as you scroll, maintaining responsive performance.

This sampling approach serves most data exploration needs perfectly. You gain insights into data structure, content patterns, and quality without downloading unnecessary volumes of information. Most analytical queries filter data significantly anyway, making complete table retrieval unnecessary.

Professional database work focuses on targeted data retrieval rather than comprehensive table dumps. As we progress through more advanced techniques, you'll learn filtering, sorting, and aggregation methods that return precisely the information you need for business decisions.

The goal of effective database querying is progressive refinement—starting with broad data understanding, then applying increasingly specific filters to isolate exactly the information required for your analysis or reporting objectives.

Now that you understand these fundamental navigation and querying concepts, you're ready for hands-on practice. Exercise 1B in your workbook provides step-by-step guidance through database browsing, file creation, code writing, and preference configuration, reinforcing everything demonstrated in this overview.


Key Takeaways

1Database servers contain multiple databases, which are organized into schemas that group related tables together
2Visual indicators in DBeaver help identify data types: numbers (123), text (A-Z), and timestamps (clock icon)
3Double-clicking tables opens data preview tabs, while the Properties panel shows table structure and column definitions
4SQL queries provide more control than GUI interfaces and are essential for complex data operations
5DBeaver executes only selected queries, unlike traditional programming environments that run entire files
6Key preferences include uppercase keywords, line numbers, and word wrap for better code readability and collaboration
7DBeaver loads data incrementally (200 rows at a time) to maintain performance with large datasets
8SQL files are plain text documents that can be saved and reopened, but require active database connections to execute

RELATED ARTICLES