0% found this document useful (0 votes)
2 views2 pages

MySQL Task Report

The document outlines basic MySQL queries for managing a school database. It includes tasks for creating databases and tables, inserting, querying, updating, deleting data, altering tables, and dropping tables. Specific SQL commands are provided for each task related to students and teachers.

Uploaded by

baigbazil59
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

MySQL Task Report

The document outlines basic MySQL queries for managing a school database. It includes tasks for creating databases and tables, inserting, querying, updating, deleting data, altering tables, and dropping tables. Specific SQL commands are provided for each task related to students and teachers.

Uploaded by

baigbazil59
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MySQL Basic Queries Task Report

Task 1: Create Database & Tables


CREATE DATABASE school;
USE school;

CREATE TABLE students (


id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
age INT,
email VARCHAR(100) UNIQUE
);

CREATE TABLE teachers (


id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
subject VARCHAR(50) NOT NULL,
salary FLOAT
);

Task 2: Insert Data


INSERT INTO students (name, age, email) VALUES
('Ali', 20, 'ali@[Link]'),
('Ahmed', 18, 'ahmed@[Link]'),
('Sara', 19, 'sara@[Link]'),
('Ayesha', 22, 'ayesha@[Link]'),
('Usman', 17, 'usman@[Link]');

INSERT INTO teachers (name, subject, salary) VALUES


('Ali', 'Math', 45000),
('Ayesha', 'English', 40000),
('Hamza', 'Science', 55000);

Task 3: Query Data


SHOW DATABASES;
SHOW TABLES;
DESC students;
SELECT * FROM students;
SELECT name, email FROM students;

Task 4: Update Data


UPDATE students SET age = 21 WHERE name = 'Ali';
UPDATE teachers SET salary = 50000 WHERE subject = 'Math';
UPDATE students SET email = 'newemail2@[Link]' WHERE id = 2;
UPDATE teachers SET subject = 'Computer' WHERE name = 'Ayesha';

Task 5: Delete Data


DELETE FROM students WHERE email = 'abc@[Link]';
DELETE FROM students WHERE age < 18;
DELETE FROM teachers WHERE name = 'Ali';
DELETE FROM teachers WHERE salary < 40000;
Task 6: Alter Table
ALTER TABLE students ADD grade VARCHAR(10);
ALTER TABLE students DROP COLUMN email;
ALTER TABLE teachers MODIFY salary INT;

Task 7: Drop
DROP TABLE students;
DROP DATABASE school;

You might also like