Lesson 13: Introduction to SQL: DDL, DML, and DCL
SQL (Structured Query Language) is the standard language used to communicate with and manage relational databases. It is not a programming language but a declarative language.
Categories of SQL Commands
SQL commands are broadly categorized into three main groups:
1. DDL: Data Definition Language
DDL commands are used to define the database schema—the structure that holds the data. They affect the organization of tables and objects.
- Commands:
CREATE: To create databases, tables, indexes, or views.ALTER: To modify the structure of an existing object (e.g., add a column).DROP: To completely remove an object (table, view, index) from the database.
2. DML: Data Manipulation Language
DML commands are used to interact with the data stored within the tables. This is what you will use most often.
- Commands:
SELECT: To retrieve data from the database (the most common command).INSERT: To add new records (rows) to a table.UPDATE: To modify existing records.DELETE: To remove records (rows) from a table.
3. DCL: Data Control Language
DCL commands are used to control access and permissions for users.
- Commands:
GRANT: To give specific access permissions to a user.REVOKE: To take away permissions.
Focus: We will spend the next several lessons mastering DML, particularly the powerful SELECT statement.