0% found this document useful (0 votes)
8K views

Lab Assignment-1 1. Create Table Student (Rno, Name, DOB, Gender, Class, College, City, Marks)

The document describes lab assignments to create tables, insert data, and write SQL queries to retrieve and manipulate data. It includes creating Student and Employee tables, inserting sample records, and writing SELECT, UPDATE, DELETE queries to retrieve, modify and delete records based on various conditions on attributes like city, name, salary etc.

Uploaded by

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

Lab Assignment-1 1. Create Table Student (Rno, Name, DOB, Gender, Class, College, City, Marks)

The document describes lab assignments to create tables, insert data, and write SQL queries to retrieve and manipulate data. It includes creating Student and Employee tables, inserting sample records, and writing SELECT, UPDATE, DELETE queries to retrieve, modify and delete records based on various conditions on attributes like city, name, salary etc.

Uploaded by

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

Lab Assignment–1

1. Create table Student (Rno, Name, DOB, Gender, Class, College, City,
Marks).
create table Student2(Rno number(5), Name varchar(10), DOB varchar(12), Gender
varchar(10), Class varchar(10), College varchar(10), City varchar(10), Marks
number(10));
2. Insert 5 records in student table
insert into Student2 values(1, 'Swati', '03/12/1995', 'FEMALE', 'ENC', 'Thapar',
'Patiala', 91);
insert into Student2 values(2, 'Kartik', '19/09/1996', 'MALE', 'ENC', 'Thapar',
'Kanpur', 92);
insert into Student2 values(3, 'Tamanna', '28/03/1997', 'FEMALE', 'ENC', 'Thapar',
'Amritsar', 93);
insert into Student2 values(9, 'Shubham', '11/10/1997', 'MALE', 'ENC', 'Thapar',
'Jodhpur', 94);
insert into Student2 values(10, 'Saif', '21/06/1997', 'MALE', 'ENC', 'Thapar',
'Patiala', 95);
3. Display the information of all the students
select * from Student2;
4. Display the detail structure of student table
desc Student2;

5. Display Rno, Name and Class information of ‘Patiala’ students


Select rno, name, class from Student2 where city='Patiala';

6. Display information on ascending order of marks


select * from Student2 order by marks;

7. Change the marks of Rno 3 to 89.


update Student2 set marks=89 where rno=3;
8. Change the name and city of Rno 9.
update Student2 set name='Shaunak',city='Lucknow' where rno=9;

9. Delete the information of ‘Amritsar’ city records


delete from student2 where city='Amritsar';

10. Delete the records of student where marks<93.

delete from student2 where marks<93;


Lab Assignment-2
1. Create table emp which has the following attributes (employee table)
(empno, ename, job, sal,commission, deptno)
Create table empsa (empno number(10),ename varchar(15), job varchar(30),salary
number(30),commission number(30),deptno number(5));
2. Insert appropriate records in above tables.
insert into empsa values(1,'Supreet','Engineer',3000,NULL,15);
insert into empsa values(2,'Shaunak','Engineer',2000,NULL,20);
insert into empsa values(3,'Shivam','Salesperson',2500,1500,15);
insert into empsa values(4,'Tamanna','Engineer',4000,NULL,25);
insert into empsa values(5,'Sudhanshu','Clerk',2100,1000,30);
insert into empsa values(6,'Ibrahim','Clerk',2300,NULL,20);
insert into empsa values(7,'Charu','Salesperson',2400,NULL,10);
insert into empsa values(8,'Airac','Clerk',1800,NULL,30);
insert into empsa values(9,'Amara','Clerk',2000,500,20);
3. Get employee no and employee name who works in dept no 10
select distinct empno,ename,deptno from empsa where deptno=10;

4. Display the employee names of those clerks whose salary > 2000
select distinct ename,job,salary from empsa where job='Clerk' and salary>2000;

5. Display name and salary of Salesperson & Clerks


select distinct ename,salary,job from empsa where job in('Salesperson' ,'Clerk');

6. Display all details of employees whose salary between 2000 and 3000
select distinct * from empsa where salary between 2000 and 3000;
7. Display all details of employees whose dept no is 10, 20, or 30
select distinct * from empsa where deptno in(10,20,30);

8. Display name of those employees whose commission is NULL


select distinct ename,commission from empsa where commission is NULL;

9. Display dept no & salary in ascending order of dept no and with in each dept no
salary should be in descending order
select distinct deptno,salary from empsa order by deptno asc,salary desc;
10. Display name of employees that starts with ‘C’
select distinct ename from empsa where ename like 'C%';

11. Display name of employees that ends with with ‘C’


select distinct ename from empsa where ename like '%c';

12. Display name of employees having two ‘a’ or ‘A’ chars in the name
select distinct ename from empsa where ename like '%a%a%' or ename like '%A%A%';

13. Display the name of the employees whose second char is ‘b’ or ‘B’
select distinct ename from empsa where ename like '_B%' or ename like '_b%';

14. Display the name of the employees whose first or last char is ‘a’ or ‘A’

select distinct ename from empsa where ename like 'A%a';

You might also like