SQL Tools and How to Run This Course's Examples
The tools people use to write and run SQL (SQL Developer, SSMS, psql, pgAdmin, DBeaver, VS Code), how to get a free database running in minutes, how applications send SQL safely with parameters, and how to read the output of this course's runnable PostgreSQL examples.
kvi5hnuCode Sprout team member12 min readOn this page
To learn SQL, you need somewhere to run it. This article covers three things:
- the tools developers use with each major database;
- how to get a real database running on your own machine;
- how the runnable examples in this course work, and how to read their output.
Two kinds of tool
Every SQL tool is a client. It sends your statements to the DBMS and shows what comes back. There are two styles:
- Command-line clients are fast and scriptable, and they're always available on servers. You type a statement, end it with a semicolon, and the tool prints the result as text.
- Graphical clients add an editor with syntax highlighting and completion, a grid for results, a browser for tables and other objects, and usually a way to view query plans.
| Database | Command line | Graphical (vendor) |
|---|---|---|
| Oracle | SQL*Plus, SQLcl | SQL Developer, and the SQL Developer extension for VS Code |
| SQL Server | sqlcmd | SQL Server Management Studio (SSMS 22), and the MSSQL extension for VS Code |
| PostgreSQL | psql | pgAdmin 4 |
| MySQL | MySQL Shell (mysqlsh), mysql | MySQL Workbench |
| SQLite | sqlite3 | DB Browser for SQLite |
Cross-database tools work with all of them through drivers. DBeaver (free) and JetBrains DataGrip, which is also built into IntelliJ IDEA Ultimate and other paid JetBrains IDEs, are the most common. They're a good choice if you work with several products.
A few habits that work in every client:
- Run one statement or the whole script. Most graphical tools run the statement under the cursor with one shortcut (often Ctrl+Enter) and the whole script with another. Learn both. Running a whole script when you meant one statement is a classic way to drop a table by accident.
- Know whether you're in auto-commit mode. Many tools commit each statement automatically. Others, such as SQL Developer by default, leave a transaction open until you
COMMIT. Article 60 explains why this matters. - Check which database or schema you're connected to before running anything that changes data. Most tools show it in the toolbar or prompt.
- Keep the reference manual open. Every vendor publishes a SQL reference: the SQL Language Reference for Oracle, the Transact-SQL reference for SQL Server, the PostgreSQL Documentation (the "SQL Commands" and "Functions and Operators" chapters), the MySQL Reference Manual, and the SQL As Understood By SQLite pages. Syntax diagrams in these manuals show every optional clause. When a statement fails with a syntax error, the manual is the fastest way to find out why.
Getting a free database
All the major products have a free edition you can run locally. The quickest way is a container. With Docker or Podman installed, each line below starts a database you can connect to with the tools above:
# PostgreSQL 18 (user postgres, password secret, port 5432)
docker run -d --name pg -e POSTGRES_PASSWORD=secret -p 5432:5432 postgres:18
# MySQL 8.4 LTS (user root, password secret, port 3306)
docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=secret -p 3306:3306 mysql:8.4
# SQL Server 2025 Developer edition (user sa, port 1433; the password needs at least 8 characters from three of: upper, lower, digit, symbol)
docker run -d --name mssql -e ACCEPT_EULA=Y -e "MSSQL_SA_PASSWORD=Str0ng!Passw0rd" -p 1433:1433 mcr.microsoft.com/mssql/server:2025-latest
# Oracle AI Database 26ai Free (connect to the FREEPDB1 service on port 1521)
docker run -d --name oracle -e ORACLE_PWD=secret -p 1521:1521 container-registry.oracle.com/database/free:latest
These are throwaway development setups: simple passwords and default settings. Never expose them to a network you don't control. You can also install the products directly. PostgreSQL, MySQL and SQL Server Developer edition all have installers for Windows and macOS, and SQLite is a single small program that's already installed on macOS and most Linux systems.
Each product also has a free sample database that's useful for practice once you've finished this course. Examples are Oracle's HR and SH schemas, Microsoft's AdventureWorks and WideWorldImporters, the PostgreSQL "pagila" and "dvdrental" databases, and MySQL's "sakila".
How applications send SQL
In production, SQL doesn't come from someone typing in a tool. It comes from application code, through a driver that implements a standard data access API:
- Java: JDBC (and frameworks built on it, such as JPA/Hibernate, jOOQ and Spring's
JdbcClient) - C# and .NET: ADO.NET (and Entity Framework, Dapper)
- Python: the DB-API (
sqlite3,psycopg,oracledb,mysql-connector), and SQLAlchemy on top - JavaScript and Node.js:
pg,mysql2,node:sqlite, and ORMs such as Prisma and Drizzle - Any language: ODBC, a C-level standard most products support
Whatever the language, the pattern is the same: open a connection, send a statement, read the rows, and close the connection. One rule matters more than any other. Values that come from users go in as parameters, never pasted into the SQL text. The SQL contains placeholders such as ?, :name or $1, depending on the driver, and the values are sent separately. The database never confuses the value with SQL code. Building SQL by concatenating strings is how SQL injection attacks happen, and article 59 shows exactly how.
How this course's examples work
The course's runnable examples are plain SQL scripts that run on a real PostgreSQL 17 server. PostgreSQL is a good reference engine. It follows the SQL standard more closely than any other popular product, and it supports almost every feature this course teaches, from window functions and MERGE to stored procedures, triggers, transactions and roles.

Here's a complete example. Click Run to execute it:
-- 1. Set up: create the tables and rows the example needs
CREATE TABLE stores (
store_id INTEGER PRIMARY KEY,
city VARCHAR(40) NOT NULL,
opened DATE,
manager VARCHAR(60)
);
INSERT INTO stores VALUES
(1, 'Leeds', '2019-04-01', 'Ines Duarte'),
(2, 'York', '2022-09-15', NULL),
(3, 'Pune', '2024-02-10', 'Ravi Menon');
-- 2. The query being taught
SELECT store_id, city, manager
FROM stores
ORDER BY store_id;
-- 3. A parameterized statement: the value is sent separately from the SQL text
PREPARE store_by_city (VARCHAR) AS
SELECT city, opened FROM stores WHERE city = $1;
EXECUTE store_by_city ('York');
EXECUTE store_by_city ('york');
-- 4. Which database answered?
SELECT current_setting('server_version_num')::int / 10000 AS postgres_major_version;
store_id | city | manager
----------+-------+-------------
1 | Leeds | Ines Duarte
2 | York |
3 | Pune | Ravi Menon
(3 rows)
city | opened
------+------------
York | 2022-09-15
(1 row)
city | opened
------+--------
(0 rows)
postgres_major_version
------------------------
17
(1 row)
Reading an example:
- Every run starts with an empty database. The script creates the tables it needs and inserts a few rows. Read the setup first, so you know exactly which rows exist. Nothing is kept after the run.
- Each
SELECTprints a table. The output comes frompsql, PostgreSQL's command-line client. It prints column names, a dashed line, the rows, and a row count such as(3 rows). Numbers are right-aligned and text is left-aligned. - NULL prints as nothing. York's manager is NULL, so that cell is blank. When the difference between NULL and an empty string matters, the examples make it visible, for example with
COALESCE(article 8). - An empty result still prints its header, followed by
(0 rows). That's what the'york'lookup produced: PostgreSQL compares text case-sensitively, so'york'doesn't match'York'. - Errors are printed where they happen, and the script carries on. An error looks like
psql:/workspace/solution.sql:12: ERROR: .... The number is the line of the script that failed. Many examples break a rule on purpose to show the error message. - Parameters.
PREPAREandEXECUTEshow, in pure SQL, what drivers do for you: the statement contains a placeholder ($1), and the value is supplied separately. - The output block under each example shows exactly what the run prints, so you can compare without running it.
To run an example on your own machine, use the Copy button and paste the script into any PostgreSQL client: psql, pgAdmin, DBeaver or the VS Code PostgreSQL extension. Use an empty database, so the example's tables don't clash with yours.
Examples for other databases
Every product has features the others lack, such as Oracle's CONNECT BY and PL/SQL, SQL Server's TOP and T-SQL, and MySQL's ON DUPLICATE KEY UPDATE. Those appear as ordinary (not runnable) code blocks, labelled with the product they're for, often with that product's output underneath. The labels look like this:
SELECT city FROM stores FETCH FIRST 2 ROWS ONLY;
When standard SQL and PostgreSQL agree, which is most of the time, the runnable example is the version to learn. When PostgreSQL has its own extension, such as LIMIT or RETURNING, the article says so and shows the standard or other-dialect equivalent.
What's current
- Microsoft retired Azure Data Studio on February 28, 2026. Its replacements are the MSSQL extension for VS Code and SSMS 22, which became generally available in November 2025.
- Oracle offers SQL Developer as a desktop application and as an extension for VS Code, and SQLcl is its modern command-line client. The free edition is now called Oracle AI Database 26ai Free.
- PostgreSQL 19 was released on November 19, 2026. The container line above uses 18, which every hosting service and tool already supports. Change the tag to
postgres:19to try the newest version. - MySQL 8.4 and 9.7 are the long-term support releases. Feature releases now use calendar version numbers, such as 26.10, which came out in October 2026.
- Node.js now includes a built-in SQLite module (
node:sqlite), and Python has always had one (sqlite3). So SQLite is available for quick experiments in either language without installing anything.
Common questions
Do I need to install anything to follow this course? No. Every runnable example runs in the page. Installing PostgreSQL or another server database is still worthwhile later, because it lets you try the dialect-specific examples and work with larger data.
Why PostgreSQL for the runnable examples?
It's free, it follows the SQL standard closely, and it supports nearly everything in this course, including features that lighter engines lack, such as FULL JOIN, MERGE, real date and interval types, procedures, triggers, roles and transactions. Code you learn on PostgreSQL transfers to other products with few changes, and the articles point out the changes you need.
Can I run the examples on MySQL, SQL Server or Oracle instead? Most of them, yes. Standard queries run unchanged. The differences you'll hit most often are covered in article 2's dialect table: row limiting, string concatenation, identifier quoting and key generation. Each article also mentions any dialect differences for its topic.
Why does psql show nothing for NULL?
That's psql's default display. A NULL is shown as an empty cell, so it looks like an empty string. Inside a client you can change it with the psql command \pset null '(null)', and graphical tools usually show [NULL] or (null). The examples use COALESCE or IS NULL when the difference matters.
What's the difference between SQL*Plus, SQLcl and SQL Developer? SQL*Plus is Oracle's classic command-line client. SQLcl is its modern replacement, with command history, completion, formatting and scripting. SQL Developer is the graphical tool. All three send the same SQL and PL/SQL to the database.
What does auto-commit mean, and should it be on?
In auto-commit mode, each statement is committed as soon as it succeeds, so there's nothing to undo. It's convenient for ad-hoc queries. When you're changing important data by hand, turn it off or start an explicit transaction, so you can check the result and ROLLBACK if something's wrong. Article 60 covers transactions.
Why should values go in as parameters? It prevents SQL injection, because a parameter can never change the structure of the statement. It also handles quoting and data types correctly, and lets the database reuse the execution plan for repeated statements.
Summary
- Every SQL tool is a client that sends statements to a DBMS. There are command-line clients (
psql,sqlcmd, SQLcl,mysqlsh,sqlite3), vendor graphical tools (SQL Developer, SSMS, pgAdmin, MySQL Workbench), and cross-database tools (DBeaver, DataGrip, VS Code extensions). - Containers are the quickest way to run PostgreSQL, MySQL, SQL Server or Oracle Free locally.
- Applications send SQL through a driver (JDBC, ADO.NET, DB-API, ODBC). User-supplied values always go in as parameters.
- This course's runnable examples are SQL scripts that run on PostgreSQL 17. Each run starts from an empty database, creates its own tables, and prints every result in psql's table format.
- In that output, NULL appears as a blank cell, an empty result prints
(0 rows), and errors are printed at the line that failed while the rest of the script still runs. - Features that PostgreSQL doesn't have appear as ordinary code blocks labelled with their product.
Practice questions
In the example, the second EXECUTE printed (0 rows). Why, and what would you change to find the store whatever case the user types?
Answer
PostgreSQL compares text case-sensitively, so 'york' doesn't equal 'York'. To match regardless of case, compare lowercased values: WHERE lower(city) = lower($1). PostgreSQL also has the non-standard ILIKE operator. Article 36 covers case-insensitive comparison and collations.
A colleague builds a query in application code as "SELECT * FROM stores WHERE city = '" + city + "'" instead of using a placeholder. Give two reasons this is worse.
Answer
- SQL injection. A value such as
x' OR '1'='1changes the meaning of the statement and returns every row. Worse values could change or delete data. - Correctness. A legitimate value containing a quote, such as
O'Brien, breaks the SQL with a syntax error.
There's also a performance cost: each distinct value produces a different statement text, so the database can't reuse a prepared statement. With a placeholder (?, $1 or :city, depending on the driver), the value is sent separately, and none of these problems can happen.
In a graphical client, you type two statements, DELETE FROM stores WHERE store_id = 2; and SELECT * FROM stores;, and press the "run statement" shortcut with the cursor on the SELECT line. What runs?
Answer
Only the SELECT. The "run statement" shortcut runs the statement under the cursor, so the DELETE is ignored. "Run script" would run both, in order. Knowing which one you pressed matters most when one of the statements changes data.
What does PostgreSQL print for this script, and why does the second insert succeed when the first one fails?
CREATE TABLE stock (product_id INTEGER, qty INTEGER);
INSERT INTO stock VALUES (1, 'twelve');
INSERT INTO stock VALUES (2, '12');
SELECT * FROM stock;
Answer
psql:/workspace/solution.sql:2: ERROR: invalid input syntax for type integer: "twelve"
LINE 1: INSERT INTO stock VALUES (1, 'twelve');
^
product_id | qty
------------+-----
2 | 12
(1 row)
A quoted literal such as '12' starts out with no fixed type. PostgreSQL converts it to the column's type, INTEGER, when it's inserted. '12' converts to 12, but 'twelve' can't be converted, so that insert is rejected and the table only gets one row. The script carries on after the error, so the SELECT still runs. Not every database is this strict: SQLite, for example, would store the text 'twelve' in the INTEGER column unless the table is declared STRICT. Article 35 covers types and conversions.
Previous: The SQL Language: Statement Types, Standards and Dialects
Next: How a SQL Query Is Processed: The Logical Order of SELECT Clauses

More in SQL Course
Quiz: SQL Dialect Differences (PostgreSQL, MySQL, SQL Server, Oracle, SQLite)
Twenty-four questions on how the major SQL databases differ: limiting rows, concatenation, empty strings, identifier case, upserts, identity columns, transactional DDL, error handling, isolation defaults, booleans, set operations, RETURNING, dates and typing.
Quiz: SQL Delicate Details
Twenty-five questions on SQL's subtle corners: NULLs in aggregates, IN and CHECK, sort order of NULLs, rounding, CHAR padding, window frame defaults, identity gaps, LIKE escapes, empty groups, set operations and multi-column updates.
Quiz: SQL Interview Questions
Thirty SQL questions of the kind asked in developer and analyst interviews: WHERE vs HAVING, DELETE vs TRUNCATE, keys, joins, duplicates, Nth-highest values, window functions, ACID, isolation, locking, indexes, views, procedures and performance.
Quiz: SQL Course Final Exam (All 15 Parts)
The final exam for the SQL course: thirty questions across all fifteen parts, from query processing, NULLs, joins and aggregation through windows, data changes, types, design, indexes, security, transactions, procedural SQL and tuning.
Discussion
Sign in to ask a question or share what you learned.