DDL (Data Definition Language) - Define database structure

CommandPurpose
CREATECreate databases, tables, indexes
ALTERModify existing database objects
DROPDelete tables or databases
TRUNCATERemove all records from a table
RENAMERename database objects

DML (Data Manipulation Language) - Manage data within tables

CommandPurpose
SELECTRetrieve data from database
INSERTAdd new records
UPDATEModify existing records
DELETERemove records

DCL (Data Control Language) - Manage permissions

CommandPurpose
GRANTGive user privileges
REVOKETake away user privileges

TCL (Transaction Control Language) - Manage transactions

CommandPurpose
COMMITSave transaction changes
ROLLBACKUndo transaction changes
SAVEPOINTSet 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