SQL statements are commands used to interact with tables (entities), columns (attributes), and rows (tuples) in a relational database.
They are grouped into two main categories — DDL and DML — each serving a different purpose.
Used to define, modify, or remove database structures such as tables.
Common DDL commands:
| Command | Purpose |
|---|---|
| CREATE | Creates new tables and defines columns. |
| ALTER | Modifies an existing table — adds, drops, or changes column definitions. |
| TRUNCATE | Deletes all rows in a table but keeps the table structure. |
| DROP | Deletes the table entirely from the database. |
➡️ Key idea: DDL deals with structure — how the database is built and organized.
Used to work with data stored in the tables — also known as CRUD operations:
Create, Read, Update, Delete.
Common DML commands:
| Command | Purpose |
|---|---|
| INSERT | Adds new data rows into a table. |
| SELECT | Retrieves (reads) data from a table. |
| UPDATE | Modifies existing data in a table. |
| DELETE | Removes data rows from a table. |
➡️ Key idea: DML deals with data — how information inside tables is created and managed.