SQL is used for managing data in Relational Database Management Systems (RDBMS). It allows users to create, read, update, and delete (CRUD) data.
Data is normalized, meaning it is split across related tables rather than stored in a single large table. Tables are connected to each other using keys.
Vertical data elements are called columns or fields. Horizontal data elements are called rows, records, or entries.
Comments #
-- Comment
/*
* Multiline
* Comment
*/
Naming Cases #
SQL is case-insensitive, but using UPPERCASE for keywords and snake_case for identifiers is recommended.
Use double quotes around identifiers to avoid conflicts with reserved keywords.
Statement Delimiter #
Statements must end with a semicolon, except for a single statement. Adding a semicolon to it is recommended, though.
Statements #
A statement consists of clauses, and a clause consists of keywords, identifiers, operators, and values (expressions).
The order of clauses must be maintained. SELECT → FROM → WHERE
SELECT name, salary FROM employees WHERE salary > 5000;Clauses
SELECT name, salaryFROM employeesWHERE salary > 5000;
Keywords
SELECTFROMWHERE
Identifiers
namesalaryemployees
Operators
>
Values (Expressions)
5000
Data Types #
String
Number
Date
Time
Boolean
File