Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
45 views

Client Server Technology

1. The document describes a client server technology practical file for a BCA 5th semester student named Rahul Choudhary. 2. It includes questions about creating tables, inserting data, displaying data, modifying tables, and performing queries using SQL. 3. The questions cover skills like creating and describing tables, inserting data, displaying data, modifying tables by adding, updating, and dropping columns, and performing queries involving single and multiple tables.

Uploaded by

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

Client Server Technology

1. The document describes a client server technology practical file for a BCA 5th semester student named Rahul Choudhary. 2. It includes questions about creating tables, inserting data, displaying data, modifying tables, and performing queries using SQL. 3. The questions cover skills like creating and describing tables, inserting data, displaying data, modifying tables by adding, updating, and dropping columns, and performing queries involving single and multiple tables.

Uploaded by

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

PRACTICAL FILE

BCA VITH SEM.


CLIENT SERVER TECHNOLOGY

Guided By:
Mrs. Shiva Gupta Lecturer, Deptt. of Computer Applications

Submitted By:
Roll No: 8550061 Name: Rahul Choudhary Class: BCA VITH SEM.

Question No -1:- Create a table Emp with following specification.


Description Employee number Name Job Manager No. Hire date Salary Commission Answer:SQL> create table emp10 2 (employee_number 3 emp_name 4 job 5 manager_no 6 hire_date 7 salary 8 commission Table created. SQL> Type Number Varchar2 Varchar2 Number Date Number Number Size 4 20 10 4 9,2 7,2 Constraint Primary key Not null

number(4) PRIMARY KEY, varchar2(20), varchar2(10), number(4), date, number(9,2), number(7,2));

Question -1- A: - show the structure of Emp table.


Answer:SQL> desc emp10 Name Null? Type ----------------------------------------- -------- ---------------------------EMPLOYEE_NUMBER NOT NULL NUMBER(4) EMP_NAME VARCHAR2(20) JOB VARCHAR2(10) MANAGER_NO NUMBER(4) HIRE_DATE DATE SALARY NUMBER(9,2) COMMISSION NUMBER(7,2) SQL>

Question -1- B :- Insert 5 tupple into Emp table.


Answer:SQL> insert into emp10(employee_number,emp_name,job,manager_no,hire_date,salary,commission) values ( 1,'mohit','manager',001,'18-jul-08',21000.00,5000.00); 1 row created. SQL> insert into emp10(employee_number,emp_name,job,manager_no,hire_date,salary,commission) values ( 2 2,'rohan','manager',002,'13-jul-08',25000.00,7000.00); 1 row created. SQL> insert into emp10(employee_number,emp_name,job,manager_no,hire_date,salary,commission) values ( 2 3,'kamal','manager',003,'01-jun-08',20000.00,4000.00); 1 row created. SQL> insert into emp10(employee_number,emp_name,job,manager_no,hire_date,salary,commission) values ( 2 4,'karan','manager',004,'20-jun-08',15000.00,3000.00); 1 row created. SQL> insert into emp10(employee_number,emp_name,job,manager_no,hire_date,salary,commission) values ( 25,'kiran','manager',005,'25-jun-08',18000.00,3800.00); 1 row created. SQL>

Question -1- C :-

Show the data in Emp table.

Answer:SQL> select *from emp10; EMPLOYEE_NUMBER ---------------------------COMMISSION ------------------1 5000 2 7000 3 4000 EMP_NAME ---------------JOB ----MANAGER_NO HIRE_DATE ------------------- --------------SALARY -----------

mohit

manager

18-JUL-08

21000

rohan

manager

13-JUL-08

25000

kamal

manager

01-JUN-08

20000

EMPLOYEE_NUMBER ---------------------------COMMISSION ------------------4 3000 5 3800 SQL>

EMP_NAME ----------------

JOB -----

MANAGER_NO HIRE_DATE ------------------- ---------------

SALARY ----------

karan

manager

20-JUN-08

15000

kiran

manager

25-JUN-08

18000

Question -2:Description Department number Department name Location

Create table department as per the following specification


Type Number Varchar2 Varchar2 Size 2 20 10 Constraint Primary key Not null In Delhi, Kolkata, Chennai & Mumbai

Answer :SQL> create table dept10 2 (dept_no number (2) PRIMARY KEY, 3 dept_name varchar 2(20), 4 location varchar 2(10)); Table created. SQL>

Question - 2 - A: - Show the structure of Department table.


Answer :SQL> desc dept10 Name Null? Type -----------------------------------------------------------------------------------DEPT_NO NOT NULL NUMBER(2) DEPT_NAME VARCHAR2(20) LOCATION VARCHAR2(10) SQL>

Question - 2- B: - Enter 4 tupples into department table.


Answer:SQL> insert into dept10 2 (dept_no,dept_name,location) values (01,'BCA','delhi'); 1 row created. SQL> insert into dept10 2 (dept_no,dept_name,location) values (02,'computer_sci','kolkata'); 1 row created. SQL> insert into dept10 2 (dept_no,dept_name,location) values (03,'Chemistry','channai'); 1 row created. SQL> insert into dept10 2 (dept_no,dept_name,location) values (04,'BBA','mumbai'); 1 row created. SQL>

Question - 2 - C: - Show the data in department table.


Answer:SQL> select *from dept10; DEPT_NO ---------1 2 3 4 SQL> DEPT_NAME -------------------BCA Computer_sci Chemistry BBA LOCATION ---------Delhi Kolkata Chennai Mumbai

Question - 2 - D: - Alter table Emp add department no. column to Emp table with default value 10.
Answer:SQL> alter table emp10 2 add(dept_no number(2) default 10); Table altered. SQL>

Question - 2 - E: - Update Department number column in Emp table to 10,20 &30 respectively.
Answer:SQL> update emp10 2 set dept_no = 20 3 where employee_number = 2; 1 row updated. SQL> update emp10 2 set dept_no = 30 3 where employee_number = 3; 1 row updated. 6

SQL> update emp10 2 set dept_no = 40 3 where employee_number = 4 4; 1 row updated. SQL> update emp10 2 set dept_no = 50 3 where employee_number =5; 1 row updated. SQL>

Question - 2 - F: - Make Department number as foreign key in Emp table which references department table.
Answer:SQL> alter table emp10 2 add foreign key(dept_no) 3 references dept10(dept_no); Table altered. SQL>

Question - 2 - G: - Alter table Emp add column father name.


Answer:SQL> alter table emp10 2 add (father_name Table altered. SQL>

varchar2(20));

Question - 2 - H :- Alter table Emp modify Father name, increase its size.
Answer :QL> alter table emp10 2 modify (father_name Table altered. SQL>

varchar2(25));

Question - 2 - I :- Alter table Emp modify Father name column change its data type in number.
Answer :SQL> alter table emp10 2 modify (father_name number(10)); Table altered. SQL>

Question - 2 - J :- Alter table Emp drop column Father name.


Answer :SQL> alter table emp10 drop column father_name; Table altered. SQL>

Question 3 A :- List employee details not belonging in department 10, 30 & 40.
Answer :SQL> select * FROM EMP10 2 WHERE dept_no not in(10,30,40); EMPLOYEE_NUMBER EMP_NAME ---------------------------- ---------------COMMISSION DEPT_NO ------------------- -----------2 rohan 7000 20 5 3800 SQL> kiran 50 JOB ----MANAGER_NO HIRE_DATE ------------------- -------------SALARY ----------

manager

13-JUL-08

25000

manager

25-JUN-08

18000

Question 3 B :- Select jobs and suppress duplicate.


Answer :SQL> select distinct(job) from emp10; JOB ---------Manager SQL>

Question 3 C :- List name of employees who dont have any manager.


Answer :SQL> select emp_name from emp10 where manager_no is null; no rows selected SQL>

Question 3 D :- List Employee whose name is Ending with S.


Answer :SQL> select emp_name from emp10 where emp_name like '%s'; no rows selected SQL>

Question 3 E :- List name, salary, PF, HRA, DA, Gross, Net salary of employee, calculate all this on the basis of employee salary as following -PF = Salary * 0.1, HRA = Salary * 0.5, DA = Salary * 0.3, Gross = Salary + HRA + DA, Net = Gross PF. Answer :SQL> select emp_name, salary, salary*0.1 "PF", salary*0.5 "HRA", salary*0.3 "DA", salary + (salary * 0.5) + (salary*0.3) "gross", salary+(salary*0.5)+(salary*0.3)-salary*0.1 "NET" from emp10; EMP_NAME ---------------NET --------------mohit 35700 rohan 42500 kamal 34000 SALARY -----------PF ---HRA ----DA ---gross --------

21000

2100

10500 6300

37800

25000

2500

12500 7500

45000

20000

2000

10000 6000

36000

EMP_NAME ---------------NET ---------------Karan 25500 Kiran 30600 SQL>

SALARY ----------

PF ----

HRA ------

DA -----

gross --------

15000 18000

1500 1800

7500 9000

4500 5400

27000 32400

10

Question 3 F :- Show the use of following function count, max, min, avg.
Answer:SQL> select count(*)from emp10; COUNT(*) ---------5 SQL> select max(salary) from emp10 where job = 'manager'; MAX(SALARY) ----------25000 SQL> select min(salary) from emp10 where job = 'manager'; MIN(SALARY) ----------15000

SQL> select avg(salary) from emp10; AVG(SALARY) ----------19800 SQL>

11

QUERYING MULTIPLE TABLES 1. List employee No, Name, department no and department name from employee and department table. Answer SQL> select e.emp_name, e.employee_number, e.dept_no, d.dept_no from emp10 e, dept10 d; EMP_NAME ---------------mohit rohan kamal karan kiran mohit rohan kamal karan kiran mohit EMP_NAME ---------------Rohan Kamal Karan Kiran Mohit Rohan Kamal Karan Kiran 20 rows selected. SQL> EMPLOYEE_NUMBER ---------------------------1 2 3 4 5 1 2 3 4 5 1 EMPLOYEE_NUMBER --------------------------2 3 4 5 1 2 3 4 5 DEPT_NO ------------10 20 30 40 50 10 20 30 40 50 10 DEPT_NO ------------20 30 40 50 10 20 30 40 50 DEPT_NO ---------1 1 1 1 1 2 2 2 2 2 3 DEPT_NO ------------3 3 3 3 4 4 4 4 4

12

SET OPERATIONS A. Union Display the different designation in department 20 & 30. Answer SQL> select job from emp10 where dept_no = 20 2 union 3 select job from emp10 where dept_no = 30; JOB ---------manager SQL> B. Intersect This jobs column to department in department 20 & 30. Answer SQL> select job from emp10 where dept_no = 20 2 intersect 3 select job from emp10 where dept_no = 30; JOB ---------manager SQL> C. Minus List the job unique. Answer SQL> select *from emp10; EMPLOYEE_NUMBER EMP_NAME ------------------------------------------COMMISSION DEPT_NO --------------------------1 mohit 5000 10 2 7000 3 4000 rohan 20 kamal 30 13 manager 3 01-JUN-08 20000 JOB ----MANAGER_NO HIRE_DATE ------------------- ---------------SALARY -----------

manager

18-JUL-08

21000

manager

13-JUL-08

25000

EMPLOYEE_NUMBER EMP_NAME -------------------------------------------COMMISSION DEPT_NO ------------------------------4 karan 3000 40 5 3800 6 1000 kiran 50 nitin 10

JOB -----

MANAGER_NO HIRE_DATE ------------------- ----------------

SALARY -----------

manager

20-JUN-08

15000

manager

25-JUN-08

18000

teacher

20-JUN-08

12000

EMPLOYEE_NUMBER EMP_NAME ------------------------------------------COMMISSION DEPT_NO ----------------------------7 papin 1300 10 8 1600 9 1700 joni 20 madan 20

JOB -----

MANAGER_NO HIRE_DATE ------------------- ---------------

SALARY ----------

teacher

12-FEB-08

15000

teacher

12-MAR-08

18000

clerk

12-MAR-08

19000

9 rows selected.

SQL> select job from emp10 where dept_no = 10 2 minus 3 select job from emp10 where dept_no = 20; no rows selected SQL>

14

NESTED QUERIS
A. List the name of the employee drawing the highest salary. Answer SQL> select emp_name from emp10 2 where salary = (select max(salary) from emp10); EMP_NAME ---------------rohan SQL> B. List all employee details whose salary is > Average salary of employees where higher data is before 0104-80. Answer SQL> select * from emp10 2 where salary >(select avg(salary) from emp10) 3 INTERSECT 4 select * from emp10 5 where hire_date < '01-apr-08'; EMPLOYEE_NUMBER EMP_NAME ------------------------------------------COMMISSION DEPT_NO -----------------------------9 madan 1700 20 SQL> JOB ----MANAGER_NO HIRE_DATE -------------------- --------------SALARY ----------

clerk

12-MAR-08

19000

15

You might also like