Typing settings could not be refreshed. Reload the page to try again.
Touch typing lesson: Programming in the SQL language
accuracy: —
accuracy:words/min: —
The accuracy rules changed. This exercise starts again from the beginning.
Saving your completed session could not be confirmed. Retry without typing it again.
Touch typing lesson: Programming in the SQL language
Touch typing is important in programming. You are more efficient when you use fast typing techniques to write code in the SQL programming language.
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 () enclose function arguments and group 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. In MySQL, case sensitivity for database and table names depends on the operating system and server settings. For typing practice, using uppercase keywords is common and helps reinforce the structure of queries.
Semicolons and statement endings
In SQL, a semicolon ; ends a statement. Interactive tools such as psql, the MySQL client, and the SQLite shell normally wait for this character before executing the statement. In psql, you can also send the current query with \g. If you see a prompt for more input instead of a result, check whether you have ended the statement.
SELECT queries and joins
Typing queries often means typing joins. PostgreSQL uses INNER JOIN, LEFT JOIN, and RIGHT JOIN. The example below specifies a join condition after ON. Other join forms use USING or NATURAL. 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 available in PostgreSQL; their availability and behavior differ between databases. MySQL includes functions such as 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 = to assign values, with commas between assignments. 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)
In PostgreSQL, CTEs are introduced with the WITH keyword. CTEs often involve multiple parentheses and commas, making them a practical typing exercise. MySQL, SQLite, and SQL Server also support CTEs. Check that each opening parenthesis has a matching closing parenthesis.
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. The example below uses PostgreSQL syntax.
SELECT customer_id,
SUM(amount) OVER (PARTITION BY customer_id ORDER BY created_at) AS running_total
FROM payments;
Parameters and placeholders
In applications, parameter placeholders depend on both the database and the driver. Native PostgreSQL prepared statements use $1, $2, MySQL prepared statements and SQLite queries can use ?, and SQL Server parameters have names such as @p1. A driver may require a different syntax, such as %s in Psycopg. Check its documentation, because these small symbols are easy to mistype.
-- PostgreSQL
SELECT * FROM users WHERE id = $1;
-- MySQL
SELECT * FROM users WHERE id = ?;
Summary
By convention, SQL keywords are often typed in uppercase. PostgreSQL folds unquoted identifiers to lowercase; other systems have different rules. 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.