SQL Basics
Overview
Database and Table Operations
Create Database
CREATE DATABASE users;Show Databases
SHOW DATABASES;Use Database
USE users;Create Table with Constraints
CREATE TABLE logins (
id INT NOT NULL AUTO_INCREMENT,
username VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(100) NOT NULL,
date_of_joining DATETIME DEFAULT NOW(),
PRIMARY KEY (id)
);Show Tables and Structure
Data Manipulation
INSERT Statement
Insert All Columns
Insert Specific Columns
Insert Multiple Records
SELECT Statement
Select All Data
Select Specific Columns
Select with Conditions
UPDATE Statement
Update Records with Conditions
Update Multiple Columns
DELETE Statement
Table Structure Modification
ALTER TABLE Operations
Add New Column
Rename Column
Modify Column Data Type
Drop Column
Add Constraints
DROP Operations
Drop Table (Permanent Deletion!)
Drop Database (Extremely Dangerous!)
Common WHERE Clause Conditions
Comparison Operators
Pattern Matching
Logical Operators
Basic Logical Operations
Operator Evaluation Examples
Symbol Operators (Alternative Syntax)
Practical WHERE Clause Examples
Operator Precedence (Critical for SQL Injection!)
Precedence Order (High to Low)
Precedence Examples
Parentheses Override Precedence
Common Precedence Gotchas
NULL Handling
Useful Functions
String Functions
Date Functions
Aggregate Functions
Security Notes
Bad Practices
Good Practices
HTB Academy Example Scenario
Common Enumeration Steps
Expected Workflow
Last updated