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

Nairit Dbms

Uploaded by

Nairit Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Nairit Dbms

Uploaded by

Nairit Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

DBMS PRACTICAL

Create following tables in SQL Server for Database Management System.

Q1. Table name: “student” ( Assign RollNo as primary key.)

Field Name Data Type Size

RollNo Int 3

Name varchar 15

Gender varchar 6

City varchar 20

DOB Date 8

Blood_Group varchar 5

Remark varchar 10

4. Insert at least 10 records in every table.

14. In the Database file Add these Fields: (Total: Datatype- Number 3 digits,
Percentage: Datatype – Number 3 digits, Grade: Datatype- Char with 2
letters)

17.Display all records of the student table, write SQL command.


18.Display the RollNo, Name and City whose name starts with A using SQL
command.
19.Display all the records from the student table whose name ends with ‘I’
using SQL command.
Ans.:

1. Create database school;


2. Use school;
3. Create table student (RollNo int (3) primary key, Name varchar (15),Gender varchar (6), City
varchar (20), DOB date, Blood_Group varchar (5), Remarks varchar(10);
4. Insert into student values(101,’Abhijeet’,’male’,’dibrugarh’,’03/11/2008’,’O+ve’,’NA’);
5. Insert into student values(102,’Abhigyan’,’male’,’dibrugarh’,’10/08/2007’,’A+ve’,’NA’);
6. Insert into student values(103,’Samreena’,’female’,’Tinsukia’,’13/06/2008’,’AB+ve’,’NA’);
7. Insert into student values(104,’Sammar’,’male’,’dibrugarh’,’25/07/2008’,’A-ve’,’NA’);
8. Insert into student values(105,’Deepak’,’male’,’Tinsukia’,’20/02/2008’,’Ab-ve’,’NA’);
9. Insert into student values(106,’Jyoti’,’female’,’Moran’,’22/02/2006’,’O-ve’,’NA’);
10. Insert into student values(107,’Abhilia’,’female’,’dibrugarh’,’14/12/2008’,’O+ve’,’NA’);
11. Insert into student values(108,’Bornil’,’male’,’Moran’,’21/10/2008’,’AB+ve’,’NA’);
12. Insert into student values(109,’Devanshi’,’female’,’dibrugarh’,’11/10/2008’,’A+ve’,’NA’);
13. Insert into student values(1010,’Deepika’,’female’,’tinsukia’,’13/06/2008’,’A-ve’,’NA’);
14. Alter table student add Total int(3);
15. Alter table student add percentage int(3);
16. Alter table student add Grade char(2);
17. Select * from student;
18. Select RollNo, Name, City from student where name like ‘A%’;
19. Select RollNo, Name, City from student where name like ‘%I’;

Q2. Table name : ‘marksheet’. Primary Key – Stud_No

Field Name Data Type Size

Stud_No Int 2

Name Varchar 15

RollNo Int 3

English int 3
Math int 3

Science int 3

10.
Display all the record in ascending order of names using SQL .

11.
Display all the record in descending order of names using SQL .

12.
Display the rollno and name whose English marks are more than 70.

13.
Display the maximum and minimum marks for English using SQL.

14.
Display the sum of marks for Math using SQL command.

15.
Display all the students record who needs improvement in Science.
(Marks from 30 to 70)

16.
Display name, rollno, marks of 3 subjects and total(as different column) in
SQL.

17.
Change the marks of English scored by roll no 102 to 89.

Solution:

1. Create database school;


2. Use school;
3. Create table marksheet(Stud_No int(2) primary key, Name varchar (15), RollNo int(3), English
int(3), Math int(3), Science int(3));
4. Insert into marksheet values (01,’Anand’,111,99,85,68);
5. Insert into marksheet values(02,’Deepak’,112,75,89,97);
6. Insert into marksheet values(03,’Ashiyana’,203,64,69,89);
7. Insert into marksheet values(04,’Aashia’,105,88,98,87);
8. Insert into marksheet values(05,’Sneran’,125,76,74,95);
9. Insert into marksheet values(06,’Abhilina’,106,68,75,55);
10. Select * from marksheet order by Name;
11. Select * from marksheet order by Name desc;
12. Select * from marksheet where English > 70;
13. Select Max(English) from marksheet;
Select Min(English) from marksheet;
14. Select Sum(Math) from marksheet;
15. Select * from marksheet where Science between 70 and 30;
16. Select RollNo, Name, English, Math, Science, English+Math+Science as “Total” from marksheet;
17. Update marksheet set English=89 where RollNo = 102;

You might also like