Typing lesson: Programming in SQL language

close and start typing

Touch typing is significant in programming. You are more efficient using fast typing techniques to write code in SQL programming language.

Let's learn more about SQL language and touch typing when coding in SQL.

Coding in SQL and touch typing

Learning SQL and practicing typing go together naturally. SQL queries are filled with parentheses, commas, operators, and quotation marks. Small mistakes, such as typing the wrong quote or forgetting a semicolon, can cause an entire query to fail. When you type in SQL, it helps to know which parts of the syntax are shared across different databases and which are specific to a given system. This article focuses mainly on PostgreSQL, but we will also mention MySQL, SQLite, and SQL Server where the syntax differs.

What is characteristic about SQL syntax?

SQL (Structured Query Language) is a declarative language. Instead of describing step by step how to retrieve data, you declare what you want. Almost every statement starts with a keyword like SELECT, INSERT, or UPDATE. The order of clauses is fixed: SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY .... PostgreSQL and MySQL share this order, so if you can type it correctly in one system, you can reuse the skill in the other.

SELECT id, name
FROM customers
WHERE active = true
ORDER BY created_at DESC;

Special characters you type often

SQL is rich in punctuation. Parentheses () surround functions and conditions. Commas , separate columns. A dot . is used for schema and table names like public.users. Single quotes '...' mark string literals. PostgreSQL uses double quotes "..." for identifiers, while MySQL uses backticks `...`. In SQL Server you may also encounter square brackets [...]. Practicing these symbols builds fluency in writing queries without breaking them by accident.

-- String literal
SELECT * FROM books WHERE title = 'War and Peace';

-- Identifier with spaces (PostgreSQL)
SELECT "Order ID", "Customer Name" FROM orders;

Uppercase and lowercase

By convention, SQL keywords are usually written in uppercase: SELECT, FROM, WHERE. This makes them easier to spot in queries, but it is not required. In PostgreSQL, unquoted identifiers are automatically lowercased, so MyTable and mytable are treated the same. MySQL behaves differently depending on the operating system. For typing practice, using uppercase keywords is common and helps reinforce the structure of queries.

Semicolons and statement endings

In PostgreSQL, every statement normally ends with a semicolon ;. Forgetting it can stop execution in tools like psql. MySQL and SQLite are more permissive in interactive shells, but semicolons remain best practice. This single character is often the reason why a query fails to run when typed quickly.

SELECT queries and joins

Typing queries often means typing joins. PostgreSQL uses INNER JOIN, LEFT JOIN, and RIGHT JOIN. Each join requires the keyword ON followed by a condition. Missing a space or mistyping the condition will break the query. Practicing joins is a good way to get used to typing symbols like = and . accurately.

SELECT c.id, c.name, o.amount
FROM customers c
INNER JOIN orders o ON o.customer_id = c.id
WHERE o.amount > 100;

Functions and expressions

PostgreSQL includes many built-in functions such as COUNT(), SUM(), and AVG(). Parentheses are required every time. Date and time functions like NOW() or DATE_TRUNC() are specific to PostgreSQL. MySQL has equivalents like CURDATE() or DATE_FORMAT(). Typing them correctly requires attention to underscores, commas, and parentheses.

SELECT DATE_TRUNC('month', created_at) AS month,
       COUNT(*) AS orders
FROM orders
GROUP BY month
ORDER BY month;

INSERT, UPDATE, DELETE

Commands that modify data involve many punctuation marks. INSERT uses parentheses and commas to list columns and values. UPDATE uses = signs separated by commas. DELETE combines keywords with conditions. These structures are almost identical in PostgreSQL, MySQL, SQLite, and SQL Server, though quoting rules may differ.

INSERT INTO users (id, name, email)
VALUES (1, 'Alice', 'a@example.com');

UPDATE users
SET name = 'Bob', email = 'bob@example.com'
WHERE id = 1;

DELETE FROM users WHERE id = 2;

Common table expressions (CTEs)

PostgreSQL relies heavily on CTEs introduced with the WITH keyword. CTEs often involve multiple parentheses and commas, making them a practical typing exercise. MySQL and SQLite support them in recent versions, and SQL Server also accepts them. Correct placement of parentheses is the most common difficulty here.

WITH recent_orders AS (
  SELECT * FROM orders WHERE created_at > NOW() - INTERVAL '30 days'
)
SELECT customer_id, COUNT(*) AS order_count
FROM recent_orders
GROUP BY customer_id;

Window functions

PostgreSQL is known for its advanced window functions. The typical syntax OVER (PARTITION BY ... ORDER BY ...) requires careful typing of parentheses and uppercase keywords. MySQL and SQL Server also support window functions, but PostgreSQL is often the reference implementation.

SELECT customer_id,
       SUM(amount) OVER (PARTITION BY customer_id ORDER BY created_at) AS running_total
FROM payments;

Parameters and placeholders

When SQL is used in applications, placeholders vary between databases. PostgreSQL uses $1, $2, MySQL and SQLite use ?, and SQL Server uses @p1. These small symbols are easy to mistype, but critical for query execution.

-- PostgreSQL
SELECT * FROM users WHERE id = $1;

-- MySQL
SELECT * FROM users WHERE id = ?;

Summary

By convention, SQL keywords are often typed in uppercase, while identifiers remain lowercase unless quoted. PostgreSQL adds double quotes for identifiers, $n placeholders, CTEs, and window functions. MySQL uses backticks and question mark placeholders. SQL Server introduces square brackets and @ parameters. SQLite keeps the syntax minimal but still requires precision. Typing SQL queries trains accuracy with punctuation, keywords, and symbols, and focusing on PostgreSQL gives practice with one of the most widely used modern databases.