MySQL Basics – PDF Notes
1. What is MySQL?
MySQL is an open-source Relational Database Management System (RDBMS). It stores data in
tables and uses SQL (Structured Query Language) to manage data.
2. Basic SQL Commands
• CREATE – Used to create database or table
• INSERT – Used to insert data into table
• SELECT – Used to retrieve data
• UPDATE – Used to update existing data
• DELETE – Used to delete data
3. Create Database & Table
CREATE DATABASE school;
USE school;
CREATE TABLE students (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
age INT,
marks INT
);
4. Insert Data
INSERT INTO students (name, age, marks)
VALUES ('Rahul', 18, 85);
5. Select Queries
SELECT * FROM students;
SELECT name, marks FROM students;
SELECT * FROM students WHERE marks > 80;
6. Update & Delete
UPDATE students SET marks = 90 WHERE name = 'Rahul';
DELETE FROM students WHERE name = 'Aman';
7. Aggregate Functions
• COUNT() – Total rows
• AVG() – Average value
• MAX() – Maximum value
• MIN() – Minimum value
• SUM() – Total sum
8. Important Tips
• Always use WHERE with UPDATE and DELETE
• SQL keywords are not case-sensitive
• Practice queries daily for mastery