Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

11

INSTITUTE OF ENGINEERING & MANAGEMENT

INSTITUTE OF ENGINEERING
&
MANAGEMENT

NAME OF THE STUDENT: MANISH PANDEY


ROLL NO.: 215
ENROLLMENT NO.: 12018002013048
SUBJECT/SUBJECT CODE: DBMS Lab(PCC-CS691)
ASSIGNMENT NO.: 1

SIGNATURE :

DATE: 21.04.2021

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

1.Make your own student table with certain necessary facts, like your id, name and

Branch.

SQL> create table student(id number,name varchar2(25), branch varchar2(25));

2. Fill up the table with the records of at least 10 of your friends.

SQL> insert all into student values (1,'Manish','CSE') into student values (2,'Akash','CSE') into student values
(3,'Shivam','CSE') into student values (4,'Abhinaw','CSE') into student values (5,'Ajay','ECE') select * from dual;

3. It sounds good if you say roll instead of id. so, change it.

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

SQL> alter table student rename column id to roll;

4. Here, I think age and address could also be added. So, append it with default address of

all students as Kolkata.

SQL> alter table student add (age int, address varchar2(50) default('Kolkata'));

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT
5. Fill up the records with individual student’s age.

SQL> update student set age=20;

6. How do I identify each student uniquely? So make roll number as your primary key.

SQL> alter table student modify roll primary key;

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

7. Don’t keep the name field blank for any record.

SQL> alter table student modify name not null;

8. Add marks column in the table and add values.

SQL> alter table student add marks number default(78);

SQL> update student set marks=70 where roll between 2 and 4;

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

9. Identify the students who have passed the exam. Cut off marks is 50%.

SQL> select roll, name, marks from student where marks > 50;

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

10. If any student fails, discard his record from the database.

SQL> delete from student where marks<50;

11. Remove the address field from your table.

SQL> alter table student drop column address;

12. Copy the contents from emp table to a new table.

SQL> create table new as select * from emp;

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

13. Show the employee records from your new table.

SQL> select * from new;

14. Show salary statement along with name of all employees whose salary>1000.

SQL> select emp_name, salary from new where salary>1000;

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT
15. How many such employees are there whose salary is within 1000 to 3000 range?

SQL> select count(emp_name) from new where salary between 1000 and 3000;

16. Give a pay hike to the employees whose salary is 1250 and 950.

SQL> update new set hike=0.3*salary where salary between 950 and 1250;

17. Suggest a meaningful name for salary hike column.

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

SQL> alter table new add hike number;

18. How many types of jobs are there in this company?

SQL> select count(distinct(job)) as "type of jobs" from new;

19. Give a salary hike of 15% to the employees who have joined the company before 31st

Dec 1981.

SQL> update new set hike=hike+0.15*salary where date_of_joining<'31-DEC-81';

SQL> update new set salary= salary+hike where date_of_joining < '31-DEC-81';

NAME : Manish Pandey ROLL NO. : 215 SEC : B


11
INSTITUTE OF ENGINEERING & MANAGEMENT

NAME : Manish Pandey ROLL NO. : 215 SEC : B

You might also like