DBMS
DBMS
DBMS
Q2: Add a column experience to the emp table. experience numeric null allowed.
Q3: Modify the column width of the job field of emp table.
Q5: create the emp1 table with ename and empno, add constraints to check the empno
value while entering (i.e) empno > 100.
SNO NUMBER(38)
EMPNAME VARCHAR2(15)
JOB VARCHAR2(15)
DEPTNO NUMBER(38)
SALARY NUMBER(7)
Q2: Insert more than a record into emp table using a single insert command.
1 row created.
Q3: Update the emp table to set the salary of all employees to Rs15000/- who are
working as ASP
Q4: Create a pseudo table employee with the same structure as the table emp and insert
rows into the table using select clauses.
EMPNAME JOB
--------------- ---------------
Thomas HOD
Revian Assist HOD
vinrana lecturer
Alya Professor
Tanu professor
Abhi ASP
Q7: List the records in the emp table orderby salary in ascending order.
Q8: List the records in the emp table orderby salary in descending order.
Q10: Display deptno from the table employee avoiding the duplicated values.
DEPTNO
----------
1
2
7
Q1: Develop a query to grant all privileges of employees table into departments table
Q2: Develop a query to grant some privileges of employees table into departments table
Q3: Develop a query to revoke all privileges of employees table from departments table
Q4: Develop a query to revoke some privileges of employees table from departments
Table
SQL> rollback;
Rollback complete.
SQL> commit;
Commit complete.
Q1: Display all the details of the records whose employee name starts with ‘A‘.
Q2: Display all the details of the records whose employee name does not starts with ‗A‘.
Q3: Display the rows whose salary ranges from 15000 to 30000.
SQL> select * from empl where salary between 15000 and 30000;
Q4: Calculate the total and average salary amount of the emp table.
Q9: Find how many job titles are available in employee table.
Q10: What is the difference between maximum and minimum salaries of employees in the
organization?
Q1: Display all employee names and salary whose salary is greater than minimum salary
of the company and job title starts with ‗M‘.
SQL> select ename,sal from emp where sal>(select min(sal) from emp where job like 'a%');
ENAME SAL
-------------------- ----------
Santhosh 15000
Ishant 15000
ken 30000
Ash 50000
Bharath 17500
Kevin 45000
Q2: Issue a query to find all the employees who work in the same job as Alex
SQL> select ename from emp where job=(select job from emp where ename='Alex');
ENAME
--------------------
Santhosh
Ishant
Anto
Alex
Q3: Issue a query to display information about employees who earn more than any
employee in dept 1.
SQL> select * from emp where sal>(select max(sal) from emp where empno=1);
Q4: Display the employee details, departments that the departments are same in both the
emp and dept.
Q5: Display the employee details, departments that the departments are not same in both
the emp and dept.
15 rows selected.
Q6: Display the Student name and grade by implementing a left outer join.
SQL> select stud1.name,gra from stud1 left outer join stud2 on stud1.name=stud2.
name;
NAME GRA
---------- -----
Q7: Display the Student name, register no, and result by implementing a right outer join.
SQL> select stud1.name, regno, result from stud1 right outer join stud2 on stud1
.name = stud2.name;
NAME REGNO RESULT
---------- ---------- ----------
joshin 101 pass
sandy 104 pass
Q8: Display the Student name register no by implementing a full outer join.
SQL> select stud1.name, regno from stud1 full outer join stud2 on (stud1.name= s
tud2.name);
NAME REGNO
---------- ----------
saandy 104
joshin 101
Sheffi 103
Rajan 102
EMPNO
----------
5
Q10: Display the details of those who draw the salary greater than the average salary.
SQL> select distinct * from emp x where x.sal>=(select avg(sal) from emp);
EMPNO ENAME JOB DEPTNO SAL
------------ --------------------- ------------------- --------------
5 ken prof 45 30000
14 Anto ap 4 50000
64 Kevin Bank 11 45000
Q1: Display all the dept numbers available with the dept and emp tables
avoiding duplicates.
DEPTNO
------
1314
1315
1316
1317
1415
1615
Q2: Display all the dept numbers available with the dept and emp tables.
SQL> select deptno from emp5 union all select DEPT_NO from dept1;
DEPTNO
----------
1314
1315
1316
1317
1315
1316
1317
1314
13154
2
12 rows selected.
Q3: Display all the dept numbers available in emp and not in dept tables and vice versa.
SQL> select deptno from emp5 minus select deptno from dept3;
DEPTNO
----------
1314
1315
1316
13154
Table created.
SQL> insert into stu_details values(123,'aakash raj',date'1999-06-12','chennai',
'chennai');
1 row created.
1 row created.
1 row created.
Table created.
1 row created.
1 row created.
1 row created.
Table dropped.
1 row deleted.
Table created.
1 row created.
1 row created.
Table created.
1 row created.
Table truncated.
EMP_NO NUMBER(4)
EMP_NAME VARCHAR2(13)
DOB DATE
ADDRESS VARCHAR2(10)
DOJ DATE
MOBILE_NO NUMBER(10)
DEPT_NO NUMBER(38)
SALARY NUMBER(6)
(iii) Convert the first letter of emp_name into capitals.
SQL> select initcap(emp_name) from emp_details;
INITCAP(EMP_N
-------------
Aakash Raj
Aakiee
Table created.
SQL> insert into book values('twilight','meyer',1000,50);
1 row created.
SQL> insert into book values('little bee','chris',500,55);
1 row created.SQL> insert into book values('kim','kipling',200,55);1
row created.
1 row created.
Table truncated.
(ii) List the author of the book which one have the price of 200.
SQL> select * from book where author like 'k%';
(iii).List the price of the book which one is between the price of 175 & 250.
SQL> select * from book where price between 175 and 250;
AUTHOR
-------------
kipling
Table created.
SQL> insert into stu_details values(123,'aakash raj',date'1999-06-12','chennai',
'chennai');
1 row created.
1 row created.
1 row created.
Table created.
SQL> insert into mark_details values(123,100,100,100,300);
1 row created.
1 row created.
STU_NAME
-------------
aakash raj
vidhya
(ii)List all the student detail that who are all located in
Chennai.
SQL> select * from stu_details where city='chennai';
Table created.
SQL> insert into customer values(124,'aakash
raj','chennai',6381052298,9876543210);
1 row created.
1 row created.
CUST_ID
----------
124
125
126
COUNT(LOAN_ID) SUM(AMOUNT)
-------------- -----------
2 1980000
(iii)Display the Custname doesn‟thold any Account nor taken any Loan
SQL> select cust_name from customer where cust_id=0;
no rows selected
Table altered.
Table created.
1 row created.
Table altered.
(ii)Drop the column salary by altering the table.
SQL> alter table emp_details drop(salary);
Table altered.
(iii)Rename the table as‟Employee‟.
SQL> alter table emp_details rename to Employee;
Table altered.
7.Create the following table with the mapping given below.
Customer (Cust_id, Cust_name, Addr, ph_no,pan_no).
SQL> create table customer(cust_id number(5),cust_name varchar(13),addr varchar(
10),ph_no number(10),pan_no number(16));
Table created.
1 row updated.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
4 rows updated.
no rows selected