SQL Syntax

Basic SQL
≈ 1 min read

SQL is made of statements

Database work is built around SQL statements: each statement describes one action — create a database object, insert data, change it, or return a result. A statement usually consists of SQL keywords, table and column names, values, and additional clauses.

SELECT id, name
FROM users;

Here, SELECT and FROM are language keywords, id and name are column names, and users is the table name. The semicolon terminates the statement and is especially useful when several commands are executed one after another.

Letter case and formatting

In most database systems, SQL keywords are case-insensitive, so SELECT and select usually mean the same thing. In this course, keywords are written in uppercase because it makes the query structure easier to see. A statement can be split across several lines — whitespace improves readability and usually does not change its meaning.

SQL dialects differ slightly. The basic constructions are similar across popular relational database systems, but some data types, functions, and syntax differ. The course starts with the common ideas of the language.