Learning SQL is one of the most valuable skills for anyone working with data, applications, or servers. This MySQL commands list for beginners covers all the essential and advanced SQL commands — organized into DML, DDL, DCL, and TCL groups.
Whether you use MySQL or MariaDB, these commands will help you manage databases, handle transactions, and control user permissions efficiently.
Table of Contents
Why You Should Learn SQL Commands
Understanding the MySQL commands list for beginners gives you full control over how data is stored, retrieved, and secured in your database. By mastering these essential SQL commands, you’ll be able to:
- Control transactions safely and effectively
- Create and modify database structures
- Insert, update, and query data efficiently
- Manage user access and permissions
MySQL MariaDB SQL Commands List for Beginners
This section covers the most essential SQL commands you need to know when starting with MySQL or MariaDB. Our MySQL commands list for beginners includes practical examples and explanations to help you understand how each command works in real database scenarios. By the end, you’ll know how to manage tables, handle queries, and optimize your data operations like a pro.
DML (Data Manipulation Language)
In the MySQL commands list for beginners, DML commands help you work directly with data inside tables. You’ll use them to insert, update, delete, and retrieve records efficiently.
1. SELECT – Retrieve Data from a Table
Description: Retrieves data from one or more tables.
Example:
SELECT * FROM users;Displays all records from the users table.
2. INSERT INTO – Add New Records
Description: Inserts new data into a table.
Example:
INSERT INTO users (name, email) VALUES ('John Doe', '[email protected]');Tip: You can insert multiple rows in one command by separating value sets with commas.
3. UPDATE – Modify Existing Records
Description: Updates existing data in a table.
Example:
UPDATE users SET email = '[email protected]' WHERE id = 1;4. DELETE – Remove Records
Description: Deletes rows from a table.
Example:
DELETE FROM users WHERE id = 5;5. WHERE – Filter Results
Description: Adds conditions to your SQL queries.
Example:
SELECT * FROM users WHERE age > 25;6. ORDER BY – Sort Query Results
Description: Sorts query results in ascending (ASC) or descending (DESC) order.
Example:
SELECT * FROM users ORDER BY created_at DESC;7. GROUP BY – Aggregate Data
Description: Groups rows that share a value so that aggregate functions (like COUNT(), SUM(), MIN(), MAX(), AVG()) can be applied.
Example:
SELECT role, COUNT(*) FROM users GROUP BY role;8. ROLLUP – Add Subtotals to GROUP BY
Description: Extends GROUP BY to include summary rows.
Example:
SELECT department, SUM(salary) FROM employees GROUP BY department WITH ROLLUP;9. LIMIT – Restrict Number of Rows Returned
Description: Limits how many results are shown.
Example:
SELECT * FROM users LIMIT 5;10. JOIN – Combine Data from Multiple Tables
Description: Retrieves data by combining rows from multiple tables. There are 4 main types of joining: INNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN.
Example:
SELECT users.name, orders.amount
FROM users INNER JOIN orders ON users.id = orders.user_id;DDL (Data Definition Language)
DDL commands in the MySQL commands list for beginners are used to define and manage the structure of your database. They help you create, alter, or drop tables and other database objects.
1. CREATE DATABASE – Create a New Database
Example:
CREATE DATABASE dbname;2. CREATE TABLE – Create a New Table
Example:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100)
);3. ALTER TABLE – Modify Existing Table Structure
Example:
ALTER TABLE users ADD COLUMN created_at TIMESTAMP;4. DROP TABLE – Delete a Table
Example:
DROP TABLE users;5. TRUNCATE TABLE – Remove All Data but Keep Table
Example:
TRUNCATE TABLE users;6. RENAME TABLE – Change Table Name
Example:
RENAME TABLE users TO customers;7. SHOW TABLES – Display All Tables in a Database
Example:
SHOW TABLES;show
8. DESCRIBE – View Table Structure
Example:
DESCRIBE users;
9. USE – Select Database to Work With
Example:
USE dbname;10. SHOW DATABASES – List All Databases
Example:
SHOW DATABASES;
DCL (Data Control Language)
Within the MySQL commands list for beginners, DCL commands are used to control access and permissions. These commands help manage user privileges and maintain database security.
1. CREATE USER – Add a New Database User
Example:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password123';2. GRANT – Give User Permissions
Example:
GRANT ALL PRIVILEGES ON dbname.* TO 'newuser'@'localhost';3. REVOKE – Remove User Permissions
Example:
REVOKE DELETE ON dbname.* FROM 'newuser'@'localhost';4. SET PASSWORD – Change User Password
Example:
SET PASSWORD FOR 'newuser'@'localhost' = PASSWORD('newpass');5. DROP USER – Delete a User Account
Example:
DROP USER 'newuser'@'localhost';TCL (Transaction Control Language)
TCL commands in the MySQL commands list for beginners ensure data integrity and consistency by managing transactions. They allow you to commit, roll back, or save changes effectively.
1. START TRANSACTION – Begin a Transaction
Example:
START TRANSACTION;2. COMMIT – Save All Changes Permanently
Example:
COMMIT;3. ROLLBACK – Undo Recent Changes
Example:
ROLLBACK;4. SAVEPOINT – Create a Checkpoint in Transaction
Example:
SAVEPOINT before_update;5. RELEASE SAVEPOINT – Remove a Savepoint
Example:
RELEASE SAVEPOINT before_update;6. SET AUTOCOMMIT – Enable or Disable Auto Save
Example:
SET AUTOCOMMIT = 0;Conclusion
This MySQL commands list for beginners gives you the foundation to query, manage, and secure your databases effectively.
From DML operations to advanced TCL transaction control, mastering these SQL commands helps you work confidently with any MySQL or MariaDB database.
If you want to learn more about server management, database tuning, and backup strategies, check out our Server & Database Tutorials category for step-by-step guides and expert tips.
If you want to go deeper into SQL syntax and database operations, visit MySQL Documentation or MariaDB Knowledge Base.



