SQL Basics
What is SQL?
Section titled “What is SQL?”Structured Query Language (SQL) is the standard language for managing relational databases.
SQL Categories
Section titled “SQL Categories”Data Definition Language (DDL)
Section titled “Data Definition Language (DDL)”- CREATE: Create database objects
- ALTER: Modify database objects
- DROP: Delete database objects
- TRUNCATE: Remove all data from table
Data Manipulation Language (DML)
Section titled “Data Manipulation Language (DML)”- SELECT: Retrieve data
- INSERT: Add new data
- UPDATE: Modify existing data
- DELETE: Remove data
Data Control Language (DCL)
Section titled “Data Control Language (DCL)”- GRANT: Give permissions
- REVOKE: Remove permissions
Basic Syntax Rules
Section titled “Basic Syntax Rules”- Statements end with semicolon (;)
- Keywords are case-insensitive
- String literals use single quotes
- Comments: — for single line, /* */ for multi-line
Data Types
Section titled “Data Types”- Numeric: INT, DECIMAL, FLOAT
- Character: CHAR, VARCHAR, TEXT
- Date/Time: DATE, TIME, DATETIME, TIMESTAMP
- Boolean: BOOLEAN or BIT
Operators
Section titled “Operators”- Arithmetic:
+, -, \*, /, % - Comparison:
=, <>, !=, <, >, <=, >= - Logical:
AND, OR, NOT - Pattern Matching:
LIKE, ILIKE - Range:
BETWEEN, IN - Null Check:
IS NULL, IS NOT NULL