Here is a complete set of MySQL notes
Here is a complete set of MySQL notes
MySQL Notes
Introduction
MySQL is a popular relational database management system (RDBMS) that uses Structured Query
Language (SQL) to interact with databases.
Key Concepts:
1. Database Operations
Create a Database
Use a Database
USE my_database;
SHOW DATABASES;
Delete a Database
2. Table Operations
Create a Table
name VARCHAR(50),
age INT,
grade CHAR(2)
);
DESCRIBE students;
Modify a Table
Add a Column:
Delete a Column:
Delete a Table
Insert Data
INSERT INTO students (name, age, grade) VALUES ('Alice', 22, 'A');
Update Data
Delete Data
4. Select Queries
Order Records
SELECT * FROM students ORDER BY age DESC;
Limit Records
5. Aggregate Functions
COUNT
SUM
AVG
MAX
MIN
6. Joins
INNER JOIN
FROM students
LEFT JOIN
FROM students
RIGHT JOIN
FROM students
7. Constraints
Example:
student_id INT,
);
8. Advanced Queries
Group By
Having Clause
SELECT grade, COUNT(*) FROM students GROUP BY grade HAVING COUNT(*) > 1;
Subquery
SELECT name FROM students WHERE age = (SELECT MAX(age) FROM students);
9. Indexes
Create Index
Drop Index
Create View
Use View
Drop View
Create Procedure
DELIMITER //
BEGIN
END //
DELIMITER ;
Call Procedure
CALL GetStudents();
12. Triggers
Create Trigger
DELIMITER //
BEGIN
END //
DELIMITER ;
This is a comprehensive summary to get started with MySQL. If you need more examples or specific
queries, let me know!