DDL (Data Definition Language) - Define database structure
| Command | Purpose |
|---|
CREATE | Create databases, tables, indexes |
ALTER | Modify existing database objects |
DROP | Delete tables or databases |
TRUNCATE | Remove all records from a table |
RENAME | Rename database objects |
DML (Data Manipulation Language) - Manage data within tables
| Command | Purpose |
|---|
SELECT | Retrieve data from database |
INSERT | Add new records |
UPDATE | Modify existing records |
DELETE | Remove records |
DCL (Data Control Language) - Manage permissions
| Command | Purpose |
|---|
GRANT | Give user privileges |
REVOKE | Take away user privileges |
TCL (Transaction Control Language) - Manage transactions
| Command | Purpose |
|---|
COMMIT | Save transaction changes |
ROLLBACK | Undo transaction changes |
SAVEPOINT | Set a rollback point |
Key Clauses Used with SELECT
WHERE - Filter results
ORDER BY - Sort results
GROUP BY - Group rows
HAVING - Filter groups
JOIN - Combine tables
DISTINCT - Remove duplicates
LIMIT - Restrict rows returned
Database