Structured Query Language (SQL) is the standard language for communicating with a MySQL server. Every query you run belongs to one of four command groups that define tables, edit rows, control access, or manage transactions.
CREATE, ALTER, DROP, and TRUNCATE.SELECT, INSERT, UPDATE, and DELETE.GRANT and REVOKE.START TRANSACTION, COMMIT, and ROLLBACK.SQL statements are easy to read when you format keywords consistently. Follow these core parsing rules so your scripts work across every environment:
; character tells MySQL where one command ends and the next begins.SELECT and FROM are case-insensitive, so writing them in uppercase separates syntax from column names.This script mixes DDL to create demo_products and DML to insert and read a row.
-- DDL: Define table structure
CREATE TABLE demo_products (
product_id INT AUTO_INCREMENT PRIMARY KEY,
product_name VARCHAR(100) NOT NULL,
price DECIMAL(10, 2) NOT NULL
);
-- DML: Add one product
INSERT INTO demo_products (product_name, price)
VALUES ('Mechanical Keyboard', 129.99);
-- DML: Read stored products
SELECT product_id, product_name, price
FROM demo_products;
| product_id | product_name | price |
|---|---|---|
| 1 | Mechanical Keyboard | 129.99 |
'text' for string literals; double quotes can behave as identifiers under ANSI_QUOTES.FROM—MySQL throws a syntax error on an extra comma before FROM.No, select and SELECT work identically, though uppercase keywords make queries much easier to scan during code reviews.
Yes, separate each statement with a semicolon ; so the client or migration runner executes them sequentially.
SELECT part of DDL or DML?SELECT belongs to DML (Data Manipulation Language) because it queries row data rather than changing table definitions.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.