← Back to MySQL Course | Chapter 1: Introduction & Basics | Lesson 2 of 8

MySQL SQL

SQL is the standard language for talking to a relational database, and its statements fall into categories -- DDL, DML, and DCL -- based on whether they define structure, manipulate data, or control permissions.

What is SQL?

SQL, or Structured Query Language, is the standard language used to communicate with a relational database -- every table you create, every row you insert, and every result you retrieve is expressed as a SQL statement sent to the database server.

Example: What is SQL?

sql
SELECT * FROM employees WHERE department = 'Sales';

SQL Statement Categories

SQL statements are grouped into categories based on what they do: statements that define the database's structure, statements that manipulate the data inside it, and statements that control who is allowed to do what.

Example: SQL Statement Categories

sql
CREATE TABLE employees (id INT);  -- defines structure
INSERT INTO employees VALUES (1); -- manipulates data
GRANT SELECT ON employees TO 'reader'@'localhost'; -- controls access

Data Definition Language (DDL)

Data Definition Language, or DDL, includes statements like CREATE, ALTER, and DROP that define or change the structure of databases, tables, and other objects, rather than touching the actual data stored inside them.

Example: Data Definition Language (DDL)

sql
CREATE TABLE products (id INT, name VARCHAR(50));
ALTER TABLE products ADD price DECIMAL(10,2);
DROP TABLE products;

Data Manipulation Language (DML)

Data Manipulation Language, or DML, includes statements like SELECT, INSERT, UPDATE, and DELETE that read and modify the actual rows of data stored in a table, without changing the table's underlying structure.

Example: Data Manipulation Language (DML)

sql
CREATE TABLE customers (id INT, name VARCHAR(50));
INSERT INTO customers VALUES (1, 'Amit');
UPDATE customers SET name = 'Amit Kumar' WHERE id = 1;
DELETE FROM customers WHERE id = 1;
SELECT * FROM customers;

Data Control Language (DCL)

Data Control Language, or DCL, includes statements like GRANT and REVOKE that manage permissions, controlling which database users are allowed to read, modify, or administer specific databases and tables.

Example: Data Control Language (DCL)

sql
GRANT SELECT, INSERT ON mydb.* TO 'app_user'@'localhost';
REVOKE INSERT ON mydb.* FROM 'app_user'@'localhost';
🔒

Chapter Quiz — Complete all 8 topics to unlock

0/8 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.