Code Examples
-- See all databases on the server
SHOW DATABASES;
-- Create a new database
CREATE DATABASE school_db;
-- Select database to use
USE school_db;
-- See current database
SELECT DATABASE();
-- Delete a database (CAREFUL — no undo!)
-- DROP DAT...
USE school_db;
CREATE TABLE students (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
age INT,
email VARCHAR(150) UNIQUE,
grade VARCHAR(5),
created_at TIMESTAMP DEFAULT CURRE...
-- Insert one student
INSERT INTO students (name, age, email, grade)
VALUES ('Sara Ahmed', 17, 'sara@example.com', 'A');
-- Insert multiple rows (more efficient)
INSERT INTO students (name, age, email, grade) VALUES
('Ali Khan', 16, 'ali@examp...