Вы находитесь на странице: 1из 28

GOVERNMENT POLYTECHNIC, AHMEDABAD

Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

Practical NO: 1
PRACTICE OF SQL-1
1.Create The table:
Employee table:
create table Employee (emp_no varchar2(10) ,name varchar2(10), basic number(10),Designation
varchar2(10),
DA number(2),HRA number(3),LOAN number(10),gross_pay number(10),net_pay number(10),dept_code
varchar2(5) ,D_O_J date);
Department Table:
create table Department(dept_code varchar2(5),d_name varchar2(10) ,location varchar2(10));
Leave TAble:
create table Leave
(emp_no varchar2(10) ,
CL char(1) check(CL in('Y','N''y','n')),
PL char(1) check(PL in ('y','Y','N','n')),
UPL char(1) check(UPL in ('y''n','Y','N')),
ML char(1) check(ML in ('y','n','Y','N')),
Leave_date date );

1.Alter table Employee modify (emp_no varchar2(10) check(emp_no like 'E%'));


2.Alter table Employee modify (dept_code varchar2(5) check(dept_code like 'D%'));
3.Alter table Department modify (location varchar2(10) check(location in
('Bombay','Ahmedabad','Baroda')));
4. a. Alter table Employee modify (emp_no varchar2(10) primary key);
b. Alter table Department modify (dept_code varchar2(5) primary key);
c. Alter table Employee modify (foreign key(dept_code) references Department);
d.Alter table Leave modify (foreign key(emp_no) references Employee);
5. a.Alter table Employee modify (basic number(10) not null);
b.alter table Department modify (d_name varchar2(10) not null,
location varchar2(10)check(location in ('Bombay','Ahmedabad','Baroda')) not null);
6.alter table Employee modify(DA number(2)check (DA>0),HRA number(3)check(HRA >0) )

Insert into Department:


insert into Department(dept_code,d_name,location) VALUES('D004','HR','Ahmedabad');
Insert into Employee:
insert into Employee (emp_no ,name, basic ,Designation ,dept_code ,D_O_J)
values('E001','Rekha ', 25000,'Manager','D001','17-feb-1997');
Insert into Leave:
insert into Leave
(emp_no,CL,PL,UPL,ML,Leave_date) values('E003','n','n','N','n','20-Jan-2011');

1
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV
Practical NO: 2
PRACTICE OF SQL-2
1) Employee

* Primary key : Ename

2) Emp_company

Ename Cname Salary Jdate


Anil ACC 1500 1-MAY-89
Shankar TATA 2000 10-JUL-90
Jaya CMC 1800 7-JUN-91
Sunil CMC 1700 1-JAN-88
Vijay TATA 5000 3-JAN-88
Prakash TATA 3000 27-MAR-89
Ajay ACC 8000 30-APR-95
Amol ACC 1000 17-MAR-95
* Primary key : (Ename,Cname)
* Foreign key 1: Ename reference to Employee
* Foreign key 2: Cname reference to Company

3) Company

Cname City
ACC Madras
TATA Bombay
CMC Bombay
* primary key : Cname
4) Manager 5) Emp_shift

Ename Mname Ename Shift


Anil Ajay Anil A
Shankar Vijay Sunil B
Jaya -- Vijay B
Sunil Jaya Prakash C
Vijay --
* Foreign key: Ename refrence to Employeee
Prakash Shankar
Ajay --

1) List names of companies located in ‘BOMBAY’.


2) List names of employees living in city ‘NAGPUR’.
3) List names of employees who are not with company ‘ACC’.

2
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

4) Get cities of companies ‘ACC’ and ‘TATA’.


5) Find name of cities that is common to companies ‘ACC’ and ‘TATA”.
6) Print cities where ‘ACC’ is located but not ‘TATA’.
7) Find employee names and cities they live in, for employee working in company ‘ACC’.
8) List employee living in city ‘Bombay’ and those having company located in city ‘Delhi’.
9) List names of employee living in same city where Sunil is living.
10) Implement above query with ‘exists’ clause.
11) Give salary of employees living in ‘Delhi’.
12) Give names of companies located in those cities where ‘TATA’ is located.
13) Give name of employee whose company is located in city ‘DELHI’.
14) Give names of employees living in the same city where their company is located.
15) Give name of employee living in city ‘BOMBAY’ and having company located in city ‘Delhi’.
16) List names of employees of’’ACC’ having salary greater than every employee of ‘TATA’.
17) List names of employees having living city ‘NAGPUR’ and company name ‘ACC’.
18) List of name of employee living the city that starts with character ‘M’.
19) List name of employee whose salary is not specified.
20) List number of employees living in Bombay.
21) List number of employees having shift A.
22) List name of employees with his living city having maximum salary in company TATA.
23) List of employee having maximum salary in their company.
24) Display number employees for each company.
25) Find average salary of each company.
26) Find out name of companies having average salary more than1500.
27) Find out average salary of company only for employees living in Delhi.
28) Find name of company having highest average salary.
29) Decrease salary of Vijay by 100 if sunil and vijay are living in city ‘MADRAS’.
30) All employees of ‘ACC’ having salary greater than 8000 are shifted to ‘TATA’. The
living city of employee is Bombay.
Practical NO: 3
TCL COMMAND COMMIT
1) EXPLAIN TRANSACTION CONTROL LANGUAGE AND DEMONSTRATE THE USE OF
TCL WITH SYNTEX.(COMMIT)
EMP TABLE
EMP_NO EMP_NAME SAL
E001 HARRY 5000
E002 BLAKE 1000
E003 JACK 5000
E004 CLARK 1000

WRITE A PL/SQL block of code that first inserts a record in EMP table and update
salries of blake and clark by 2000 and 1500 respectively use COMMIT.

3
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

Practical NO: 4
TCL COMMAND ROLLBACK
1) EXPLAIN TRANSACTION CONTROL LANGUAGE AND DEMONSTRATE THE USE OF
TCL WITH SYNTEX (ROLLBACK).
WRITE A PL/SQL block of code that first inserts a record in EMP table and update
salries of blake and clark by 2000 and 1500 respectively.If the total exceeds 20000
then undo all the changes (Use ROLLBACK)

Practical NO: 5
TCL COMMAND SAVEPOINT
1) EXPLAIN TRANSACTION CONTROL LANGUAGE AND DEMONSTRATE THE USE OF
TCL WITH SYNTEX.( SAVEPOINTS).
WRITE A PL/SQL block of code that first inserts a record in EMP table and update
salries of blake and clark by 2000 and 1500 respectively.If the total exceeds 20000
then undo Updates to blake and clark (Use ROLLBACK TO SAVEPOINT)

Practical NO: 6
DCL COMMAND GRANT
1) Grant select privilege to user name ‘user1’ on EMP table.
2) Grant insert, update privileges to user name ‘user2’ on EMP table.
3) Grant All privileges to user name ‘user5’ on EMP table.
4) Grant All privileges to user name ‘user4’ on EMP table WITH GRANT OPTION.

Practical NO: 7
DCL COMMAND REVOKE
1) Revoke select privilege from ‘user1’ on EMP table.
2) Revoke all the privileges from ‘user5’ on EMP table.

Practical NO: 8
CREATE SYNONYMS
1) Create synonym for client_master table.
2) Drop synonym and list advantages of synonym.

Practical NO: 9
LOCKING
1) Demonstrate locking using select for Update on EMP table.
2) Demonstrate locking using select for Update with NOWAIT clause on EMP table.
3) Demonstrate locking using LOCK table command on EMP table.
4) Demonstrate locking using LOCK table command on EMP table with NOWAIT.

4
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV
Practical NO: 10
CREATE SEQUENCE
1) Create a sequence which will generate numbers from 1 to 100 in ascending order.
Restart the sequence with number 1
2) Alter the above sequence to generate numbers in descending order.
3) Drop sequence.
Practical NO: 11
CREATE INDEX
1) Create duplicate index on emp_no column of EMP table.
2) Create Unique index on emp_no column of EMP table.
3) Use ROWID to delete duplicate values from EMP table.

Practical NO: 12
CREATE, ALTER AND UPDATE VIEWS
1) Create a view from EMP table having emp_no,ename. Perform insert,update and
delete operation on view. List observations.

Saler_order
Column Data Type Size Attributes
Name
Order_no Varchar2 6 Primary key
Order_date date
Dely_Addr Varchar2 25

Sales_order_details
Column Data Type Size Attributes
Name
Detorder_no Varchar2 6 Primary key / foreign key references Order_no
of sales_order table.
Product_no Varchar2 6 Primary key
Qty_ordered Number 8
Qty_disp Number 8

2) Create a view from sales_order and sales_order_details tables (without


referencing clause).
Perform insert, update and delete operation on view. List observations
3) Create a view from sales_order and sales_order_details tables (with referencing
clause). Perform insert, update and delete operation on view. List observations

5
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

Practical NO: 13
CREATE SIMPLE PL/SQL PROGRAM
WRITE A PL/SQL BLOCK FOR FOLLOWING:
1) TO PRINT YOUR NAME ON SCREEN.
2) TO ADD/ SUBTRACT/MULTIPLY/DIVIDE TWO NUMBERS.
3) TO FIND SIMPLE INTEREST.

PRACTICAL NO: 14
CREATE SIMPLE PL/SQL PROGRAM USING CONTROL STRUCTURES
(CONDITIONAL CONTROL)
1) TO FIND GIVEN NUMBER IS EVEN OR ODD.
2) TO FIND MAXIMUM NUMBER FROM THREE.
3) TO FIND MINIMUM NUMBER FROM THREE.
4) TO CHECK WHETHER THE GIVEN NUMBER IS PRIME OR NOT.
5) TO CHECK WHETHER THE GIVEN NUMBER IS ARMSTRONG OR NOT.

PRACTICAL NO: 15
CREATE SIMPLE PL/SQL PROGRAM USING CONTROL STRUCTURES
(ITERATIVE CONTROL USINGLOOP)
1) TO PRINT FIRST 10 NUMBERS IN REVERSE ORDER USING FOR LOOP.
2) TO FIND SUM OF FIRST 10 NUMBERS USING FOR LOOP.
3) TO REVERSE A NUMBER 5639.

PRACTICAL NO: 16
CREATE SIMPLE PL/SQL PROGRAM USING CONTROL STRUCTURES
(ITERATIVE CONTROL USING WHILE)
1) TO FIND THE REVERSE OF THE GIVEN NUMBER.
2) TO FIND WHETHER THE GIVEN NUMBER IS PALINDROME OR NOT.
3) TO FIND SQUARE OF FIRST 10 NUMBERS USING WHILE LOOP.
4) TO FIND FACTORIAL OF A GIVEN NUMBER.
5) TO FIND TOTAL OF FIRST N NUMBERS.

PRACTICAL NO: 17
CREATE SIMPLE PL/SQL PROGRAM USING CONTROL STRUCTURES
(ITERATIVE CONTROL USING FOR)
1) DETERMINE THE BALANCE FOR GIVEN ACCOUNT. IF IT IS BELOW 5000, DEDUCT A
FINE OF RS. 100 FROM THE BALANCE AND DISPLAY IT.
2) READ ACCOUNT NUMBER FROM TWO DIFFERENT ACCOUNTS. FIND THE HIGHEST
BALANCE FROM THESE TWO ACCOUNTS AND DISPLAY IT ALONG WITH ITS
ACCOUNT NUMBER.
3) READ THE ACCOUNT NUMBER AND DELETE THAT ACCOUNT.

6
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

PRACTICAL NO: 18
CREATE SIMPLE PL/SQL PROGRAM USING CONTROL STRUCTURES
(SEQUENTIAL CONTROL )
1) If the price of product ‘P0001’ is less than 4000, then change the price to 4000. The price
change is to be recorded in old_price_table along with Product_no and date of change. (USE
GOTO)
Product_master
Product_no Sell_price
P00001 3200
P00002 4000
P00003 6000
P00004 9000
P00005 2800

Old_price
Product_no Date_change Old_price

PRACTICAL NO: 19
CREATE SIMPLE CURSORS-1
1) EXPLAIN IMPLICIT CURSORS WITH EXAMPLE.

PRACTICAL NO: 20
CREATE SIMPLE CURSORS-2
1)

7
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/201
/04/2019 Subject: ADBMS (3340701)
Subject
Staff: C K BHAVSAR Semester: IV

8
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV
2)

9
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV
PRACTICAL NO: 21
CREATE SIMPLE PL/SQL PROGRAM USING EXCEPTION HANDLING
1)

10
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV
2)

11
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

3)

12
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

13
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

PRACTICAL NO: 22
CREATE SIMPLE PL/SQL PROGRAM USING PROCEDURES
1) EXPLAIN STORED PROCEDURES WITH EXAMPLE.

14
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

15
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

16
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

17
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

PRACTICAL NO: 23
CREATE SIMPLE PL/SQL PROGRAM USING FUNCTIONS
1) EXPLAIN FUNCTIONS WITH EXAMPLE.

18
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

19
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

20
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

2) DIFFERENCE BETWEEN PROCEDURE AND FUNCTON.

21
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

PRACTICAL NO: 24
CREATE PACKAGES
1) CREATE SIMPLE PACKAGE WITH EXAMPLE.

22
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

23
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

24
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

Practical NO: 25
Create simple Triggers
1) EXPLAIN TRIGGERS WITH EXAMPLES.

25
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

26
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

PRACTICAL NO: 26
FUNCTIONAL DEPENDENCIES
1) EXPLAIN FUNCTIONAL DEPENDENCIES WITH EXAMPLES.

PRACTICAL NO: 27
PRACTICE ON NORMALIZATIONS-2

1) EXPLAIN NORMALIZATION WITH ITS TYPES AND EXAMPLE.


2) FOLLOWING RELATION FOR A PUBLISHED BOOK IS GIVEN
BOOK (BOOK-TITLE, AUTH-NAME, BOOK-TYPE, LIST-PRICE, AUTHAFFL, PUBLISHER)
AUTHAFFL REFERS TO THE AFFILIATION OF AUTHOR SUPPOSE THAT THE FOLLOWING
FDS EXIST.
BOOK-TITLE->PUBLISHER, BOOK-TYPE
BOOK-TYPE->LIST-PRICE
AUTH-NAME->AUTH-AFFL
APPLY NORMALIZATION UNTIL THE RELATIONS CANNOT BE DECOMPOSED ANY
FURTHER.
PRACTICAL NO: 28
PRACTICE ON TRANSACTION PROCESSING
1) Check weather following schedules are conflict serializable or not

27
GOVERNMENT POLYTECHNIC, AHMEDABAD
Computer Department
Practical List
Term Date: 09/12/2019 to 08/04/2019 Subject: ADBMS (3340701)
Staff: C K BHAVSAR Semester: IV

2) Check Above schedules for view serializability.

28

Вам также может понравиться