SQL: Syntax

SQL is not case sensitive, so you can use the keywords in uppercase like SELECT or lowercase like select, both work the same.

For the sake of clarity and readability, it is advised to use the reserved keywords in uppercase, while the referenced tables and fields are written in lowercase.

Some databases do not require semicolon ; at the end of a statement, but as a general rule, always use it.

For instance, a SELECT statement has the following general look based on what was specified before:

SELECT column_name FROM table_name;

Notice that you can easily identify that SELECT and FROM are reserved keywords in SQL, while column_name and table_name reference a field and a table respectively.

The most fundamental commands are:

  • SELECT: reads/extracts the data
  • INSERT: inserts new data
  • UPDATE: updates the existing data
  • DELETE: removes the data

You will see them commonly referred to as CRUD, an acronym for Create, Read, Update, and Delete.

Together they form the basis of any program that needs to interact with a database.