38. Write command and queries to create and manipulate the records of a table named 'Students' with the following fields
Roll_No
Name
Class
Marks
101
Ajay
Х
765
107
Suraj
IX
865
109
Simran
X
766
103
Aman
IX
821
104
Naresh
IX
1
a.
Write SQL commands to create the above-given table. Set appropriate datatypes for the fields.
b. Write a query to display the details of all the students studying in class X.
Write the query to change the Roll_No of the student named Aman to 106.
d. Write a query to delete the record where the value of Marks is 1.
C.
Answers
Answered by
23
a) #creating the table
Create table Students(Roll_No char(3) Primary Key, Name varchar(30), Class char(2), Marks int);
#inserting the records
Insert into Students values(101, 'Ajay', 'X', 765);
Insert into Students values(107, 'Suraj', 'IX', 865);
Insert into Students values(109, 'Simran', 'X', 766);
Insert into Students values(103, 'Aman', 'IX', 821);
Insert into Students values(104, 'Naresh', 'IX', 1);
b) #to display the details of all the students studying in class X.
Select * from Students where Class = 'X';
c) #to change the Roll_No of the student named 'Aman' to 106.
Update Students set Roll_No = 106 where Name = 'Aman';
d) #to delete the record where the value of Marks is 1.
Delete from Students where Marks = 1
Similar questions