You are on page 1of 7

Name: Akash Baranwal Roll:209

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

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

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

insert all into student values(1,'manish', 'CSE') into student values (2,'rohit','CSE') into
student values (3,'saurabh','CSE') into student values (4,'adarsh','CSE') into student values
(5,'anisha','CSE') into student values (6,'amardeep','CSE') into student values
(7,'mrinal','CSE') select * from dual;

3. It sounds good if you say roll instead of id. so, change it.
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.

alter table student add (age int , address varchar2(50) default('kolkata'));

5. Fill up the records with individual student's age.

update student set age=20;

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

Alter table student modify roll primary key;


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

alter table student modify name not null;

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

alter table student add marks number default(55);


update student set marks=70 where roll between 1 and 4;
update student set marks=40 where roll between 5 and 7;

9. Identify the students who have passed the exam. Cut off marks is 50%.
select roll, name, marks from student where marks >50;

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

Delete from student where marks<50;

11. Remove the address field from your table.

Alter table student drop column address;

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


Create table new as select * form emp;

13. Show the employee records from your new table.

Select * from new;

14. Show salary statement along with name of all employees whose salary&gt;1000.

Select emp_name, salary from new where salary>1000;

15. How many such employees are there whose salary is within 1000 to 3000 range?
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.

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

17. Suggest a meaningful name for salary hike column.


alter table new add hike number;

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

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.
update new set hike=hike + 0.15*salary where date_of_joining<'31-DEC-81' ;
update new set salary=salary+hike where date_of_joining<'31-DEC-81' ;

You might also like