0% found this document useful (0 votes)
14 views

Abhiman LAB

Uploaded by

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

Abhiman LAB

Uploaded by

abhimansaharan74
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

LAB2-

ASSIGNMENT
Abhiman Singh-
E23CSEU0174

Questions:
1. Create a database named as Bennett University.
2. Create three tables named as courses, instructors,
students.
3. Display all columns of the table courses.
4. Display all students who are in semester 3.
5. Find all records in the instructor table with null values in
name column.
6. Find students in the 3 rd semester and age above 18.
7. Find all the instructor whose department is either CSE or
MBA.
8. Add a column name as blood group in student table.
9. Delete the recently added column in the student table.
10. Change datatype of any column.
11. Change the column name of any table.
12. Delete the students whose age is >30.

Abhiman Singh – E23CSEU0174


Code for these questions:

CREATE DATABASE Bennett_University;


USE Bennett_University;
CREATE TABLE courses (
Course_code VARCHAR(10) PRIMARY KEY,
Course_title VARCHAR(50),
Credits INT,
Semester INT,
Instructor_id INT,
FOREIGN KEY (Instructor_id) REFERENCES
instructors(Instructor_id)
);

CREATE TABLE instructors (


Instructor_id INT PRIMARY KEY,
Instructor_name VARCHAR(50),
Department VARCHAR(50)
);

CREATE TABLE students (


Registration_id VARCHAR(10) PRIMARY KEY,
S_Name VARCHAR(50),
Semester INT,
Course_code VARCHAR(10),

Abhiman Singh – E23CSEU0174


Age INT,
Instructor_id INT,
FOREIGN KEY (Course_code) REFERENCES
courses(Course_code),
FOREIGN KEY (Instructor_id) REFERENCES
instructors(Instructor_id)
);
SELECT * FROM courses;
SELECT * FROM students WHERE Semester = 3;
SELECT * FROM instructors WHERE Instructor_name IS NULL;
SELECT * FROM students WHERE Semester = 3 AND Age > 18;
SELECT * FROM instructors WHERE Department IN ('CSE',
'MBA');
ALTER TABLE students ADD Blood_group VARCHAR(5);
ALTER TABLE students DROP COLUMN Blood_group;
ALTER TABLE students MODIFY Age VARCHAR(3);
ALTER TABLE students CHANGE COLUMN S_Name
Student_Name VARCHAR(50);
DELETE FROM students WHERE Age > 30;

Abhiman Singh – E23CSEU0174

You might also like