Practical No SQL
Practical No SQL
20
Create a student table with
(StudentID,Name,Marks)as attributes where
“StudentID”is a primary key.
Source code:
Create table student
(StudentID varchar(3) primarykey,
Name char(25) notnull,
Marks int(3) check(Marks<45);
Practical no.21
Insert the details of the students in the above
table.
Source code:-
Insert into student
Value(121,Luna,85),(136,Alex,87),(134,
Alice,100),(85,Cami,45),(8,Billie,76);
Practical no.22
Delete the tha details of the student name
cami form the table.
Source code:-
Delete form student
Where Name like “cami”;
Practical no.23
Use select command to get the detail of the
student with Marks more then ‘50’.
Source code:-
Select *
from student
where Marks>50;
Practical no.24
Create a new table
“order”(OrderID,Cust_name,Order_date).By
joining this table customer(CustID,OrderID).
Source code:-
Select OrederID,Cust_name,Order_date,
Cust_name
Form order,customer
Where order.OrderID=customer.OrderID;
Practical no.25
Find MIN,MAX,SUM,AVG of Marks in table
student.
Source code:-
SelectMIN(Marks),MAX(Marks),SUM(Marks),
AVG(Marks)
From student;
Practical no.26
Find total number of student in the table
student.
Source code:-
Select count(StudentID)
From student;
Practical no.27
Write a query to order student ID in student
table in descending order of Marks.
Source code:-
Select*
From student
Order by marks ascending=”false”;
Practical no. 28
Edit the detail of the student using update.
Source code:-
Update student
Set Name=”Ben”
Set Marks=”86”
Where StudentID=136;
Practical no.29
Alter student table from the student table by
adding a new column.
Source code:-
Alter table student
Add coloum percentage varchar 3
notnull;
Practical no. 30
Delete the whole table.
Source code:-
Drop table student;