In: Computer Science
Assume the following relations are given,
Student: <StudentiD, Name, Surname, Major, YearStarted>
Write necessary queries for the followings:
1- Create the table and define necessary constraints (primary key, null constraint, etc.).
2- Insert at least 5 records into the table using Insert SQL.command.
3- Select all students having a major of Computer Engineering, print their name and student ID.
4- Update starting year of all Engineering students to 2015 (use like clause).
5- Delete all student with starting year less than 2010.
6- List all records and verify the results.
7- Drop the table.
1.
CREATE TABLE STUDENT (StudentID INT primary key , Name varchar(30) not null, Surname varchar(30) not null, Major varchar(30), Year INT);
2.
INSERT INTO Student VALUES(1,'Mayank','Bhardwaj','Computer Science',2018);
3.
SELECT Name,Surname,StudentID FROM Student WHERE Major = "Computer Engineering";
4.
UPDATE TABLE SET YEAR = 2015 WHERE Major like '%Engineering%';
5.
DELETE FROM Student WHERE Year < 2010;
6.
SELECT * FROM Student;
7.
DROP TABLE Student;