Tuesday, 10 March 2015

TIME TABLE

Time table for 2nd semester

09-April-2015  :  ENGLISH
11-April-2015  :  HINDI/KANNADA
15-April-2015  :  BASIC of NETWORKING
17-April-2015  :  CPP
22-April-2015  :  DBMS
24-April-2015  :  HR

Saturday, 7 March 2015

DBMS LAB Part-B 4

Ex : 4
Create two tables Production_detail and Purchased_detail with the following fields:
Production_detail (Product_no, Product_name, Qty_available, Price Profit(%))
Purchased_detail (Cust_name, Product_no, Qty_sold)

Create table product_detail
SQL> create table product_detail(
    Prno varchar2(6) primary key,
    prname varchar2(15) not null,
    quantity number(3) not null,
    price number(6) not null,
    profit number(3) not null,
    check(prno like 'p%'));

Table created.

Display table fields
SQL> desc product_detail;

Name               Null?                  Type
-----------------------------------------------------
PRNO              NOT NULL        VARCHAR2(6)
PRNAME            NOT NULL        VARCHAR2(15)
QUANTITY     NOT NULL        NUMBER(3)
PRICE             NOT NULL        NUMBER(6)
PROFIT            NOT NULL        NUMBER(3)

Insert values into table
SQL> insert into product_detail values(
     'p001','monitor',10,4500,20);

1 row created.

SQL> select * from product_detail;

PRNO   PRNAME           QUANTITY     PRICE    PROFIT
---------------------------------------------------------------------------------
p001   monitor                10      4500        20
p002   pendrive               50       250          5
p003   CDdrive                 5       950          8
p004   keyboard                8       250         10








Create table purchased_detail
SQL> create table purchased_detail(
   Custname  varchar2(15) not null,
   prno      varchar2(6) references product_detail(prno),
   qty_sold  number(3) not null,
   primary key(custname,prno));

Table created.

Display table fields
SQL> desc purchased_detail;

Name               Null?                      Type
--------------------------------------------------------------------
CUSTNAME         NOT NULL          VARCHAR2(15)
PRNO             NOT NULL          VARCHAR2(6)
QTY_SOLD         NOT NULL          NUMBER(3)

Insert values into table
SQL> insert into purchased_detail values(
   'raman','p003',2);

1 row created.

SQL> select * from purchased_detail;

CUSTNAME        PRNO       QTY_SOLD
------------------------------------------------------
raman           p003           2
laxman          p002           5
bharath         p002          10
manish          p001           3
amith           p004           2

1. Query to display total amount spend by Mr. Laxman for purchasing any product. 

SQL> select (p.price*c.qty_sold) "Total amount"
    from product_detail p,purchased_detail c
    where p.prno=c.prno and
    c.custname='laxman';

Total amount
-----------------
1250



2. Query to display the name of product for which either quantity available is less than 10 or quantity sold is less than 4

SQL> select p.prname
    from product_detail p,purchased_detail c
    where p.prno=c.prno and
    (p.quantity<10 or c.qty_sold<4);

PRNAME
--------------
CDdrive
monitor
keyboard

3. Query to display the name of product and quantity taken by Mr. Bharath.

SQL> select p.prname,c.qty_sold
    from product_detail p,purchased_detail c
    where p.prno=c.prno and
    c.custname='bharath';

PRNAME           QTY_SOLD
-------------------------------------
pendrive               10

4. How much the profit does the shop keeper gets on Mr. Manish purchase?

SQL> select (p.price*c.qty_sold*profit/100) "Profit"
    from product_detail p,purchased_detail c
    where p.prno=c.prno and
    c.custname='manish';

   Profit
   --------
   2700

5. How many “Pen drives” have sold?
SQL> select sum(c.qty_sold) "Pendrives sold"
    from product_detail p,purchased_detail c
    where p.prno=c.prno and
    p.prname='pendrive';

Pendrives sold
------------------
15

DBMS LAB Part-B 3


Ex : 3
Create two tables Department_detail and Employee_detail with the following fields:
Department_detail (DEPTNO, DEPTNAME, TOTEMP, CHARGE/HOUR, BONUS%PER_HOUR)
Employee_detail (EMPNAME, DEPTNO, TOTAL_HOURS)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create table department_detail

SQL> create table department_detail(
    deptno varchar2(6) primary key,
   deptname varchar2(15) not null,
   totemp number(3) not null,
    charge_hour number(5) not null,
    bonus_per_hr number(3) not null,
    check (deptno like ‘d%’));

Table created.

Display table fields
SQL> desc department_detail;

Name               Null?               Type
---------------------------------------------------------------------
DEPTNO          NOT NULL           VARCHAR2(6)
DEPTNAME          NOT NULL          VARCHAR2(15)
TOTEMP          NOT NULL           NUMBER(3)
CHARGE_HOUR    NOT NULL           NUMBER(5)
BONUS_PER_HR   NOT NULL           NUMBER(3)

Insert values into table
SQL> insert into department_detail values(
   ‘d001’,’accounts’,5,750,10);

1 row created.

SQL> select * from department_detail;

DEPTNO  DEPTNAME  TOTEMP   CHARGE_HOUR   BONUS_PER_HR
------------------------------------------------------------------------------------------
d001         accounts            5              750                10
d002         sales                  10             2000                10
d003         service               5               500                10
d004         purchase            4               600                10


Create table employee_detail
SQL> create table employee_detail(
Empname varchar2(15) not null,
deptno varchar2(6)references department_detail(deptno),
total_hours number(3) not null,
primary key(empname, deptno));

Table created.

Display table fields
SQL> desc employee_detail;

Name              Null?                      Type
--------------------------------------------------------------------------
EMPNAME         NOT NULL            VARCHAR2(15)
DEPTNO          NOT NULL            VARCHAR2(6)
TOTAL_HOURS     NOT NULL            NUMBER(3)

Insert values into table
SQL> insert into employee_detail values(
     'raman','d002',8);

1 row created.

SQL> select * from employee_detail;

EMPNAME         DEPTNO TOTAL_HOURS
---------------------------------------------------------------
raman           d002             8
deekshith       d001             6
ramnath         d003             4
naveen          d002             7
shyam           d004             5

1. Query to display employee name, department number and department name of all employees.

SQL> select e.empname,e.deptno,d.deptname
    from department_detail d,employee_detail e
    where d.deptno=e.deptno;

EMPNAME         DEPTNO DEPTNAME
----------------------------------------------------------
raman           d002   sales
deekshith       d001   accounts
ramnath         d003   service
naveen          d002   sales
shyam           d004   purchase

2. Query to display the department name to which Mr. Ramnath belongs to.

SQL> select d.deptname from department_detail d, 
     employee_detail e
     where d.deptno=e.deptno and
     e.empname='ramnath';

DEPTNAME
-----------------
Service

3. Query to display the bonus got by Mr. Raman.

SQL> select(d.charge_hour*e.total_hours
     *d.bonus_per_hr/100)   "bonus"
    from department_detail d,employee_detail e
    where d.deptno=e.deptno and
    e.empname='raman';

    Bonus
    --------
    1600

Query to display the total number of hours taken by accounts department.

SQL> select sum(e.total_hours) "total hours"
    from department_detail d,employee_detail e
    where d.deptno=e.deptno and
    d.deptname='accounts';

total hours
--------------
6

DBMS LAB Part-B 2

Ex : 6
Create two table’s employee_master and attendance with the following fields:
Employee_master(emp_id, emp_name, emp_add, phone, email, boj, dor).
Attendance (emp_id, wom, mhrs, tuhrs, whrs, thhrs, frhrs, sahrs, suhrs).
Identify primary and foreign keys. Specify the not null property for mandatory keys (doj<dor and valid values of wom<=5)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create table employee_master
SQL> create table employee_master(
    emp_id number(6) primary key,
    emp_name varchar2(20) not null,
    emp_add varchar2(30) not null,
    phone number(10),
    email varchar2(30),
    doj date not null,
    dor date not null,
    check (doj<dor));

Table created.

Display table fields
SQL> desc employee_master;

Name                Null?             Type
----------------------------------------------------
EMP_ID             NOT NULL         NUMBER(6)
EMP_NAME           NOT NULL         VARCHAR2(20)
EMP_ADD            NOT NULL         VARCHAR2(30)
PHONE                      NOT NULL         NUMBER(10)
EMAIL                        NOT NULL         VARCHAR2(30)
DOJ                NOT NULL         DATE
DOR                NOT NULL         DATE

Insert values into table
SQL>   insert into employee_master
       values(2001,'harsha','kavoor',224560,
       'harsha@yahoo.com','30-jun-1985','15-jan-1997');

1 row created.

SQL> select * from employee_master;
 



EMP_ID  EMP_NAME    EMP_ADD   PHONE           EMAIL          DOJ                  DOR
-------------------------------------------------------------------------------------------------
2001      harsha              kavoor      224560   harsha@yahoo.com     30-JUN-85    15-JAN-97

2002      mahesh        bejai          254608   mahesh@yahoo.com  25-MAR-96 10-MAY-10

2003      swarna        balmatta   268754                                              23-JUL-00   12-AUG-16

2004      priya          kulur         268945                                             21-DEC-02  29-DEC-15

2005      hema            pvs             258743                                     15-NOV-96  31-JAN-13

2006      preetham     marakada  268745  preethu@yahoo.com   21-OCT-90   25-SEP-14

2007      shilpa        madikeri     268475                                             24-APR-10 30-OCT-20

2008      manasa       Bangalore                    man@www.com           05-JUL-94    05-JUL-19

2009     rashmi        kavoor                     ras@www.com              15-JUL-90  18-SEP-16

Create table attendance
SQL> create table attendance (
     emp_id number(6) references employee_master(emp_id) 
     on delete cascade,
     wom number(1) not null,
     mhrs number(3) not null,
     tuhrs number(3) not null,
     whrs number(3) not null,
     thhrs number(3) not null,
     frhrs number(3) not null,
     sahrs number(3) not null,
     suhrs number(3) not null,
     check (wom<=5));

Table created.

Display table fields
SQL> desc attendance;

Name                 Null?             Type
-----------------------------------------------------
EMP_ID              NOT NULL             NUMBER(6)
WOM                  NOT NULL        NUMBER(1)
MHRS                 NOT NULL        NUMBER(3)
TUHRS               NOT NULL        NUMBER(3)
WHRS                NOT NULL        NUMBER(3)
THHRS              NOT NULL        NUMBER(3)
FRHRS               NOT NULL        NUMBER(3)
SAHRS               NOT NULL        NUMBER(3)
SUHRS               NOT NULL        NUMBER(3)

Insert values into table
SQL> insert into attendance values(
     2002,2,4,6,7,5,8,0,0);

1 row created.

SQL> select * from attendance;

EMP_ID  WOM  MHRS  TUHRS  WHRS  THHRS  FRHRS SAHRS  SUHRS
----------------------------------------------------------------------------------------    
2002         2         4           6               7           5             8            0             0
2001         1         6           0              11          3             4            0             0
2005         3         6           8               9           0             1            0             0
2001         5         0           0               5           3             0            0             0
2009         2         5           3               0           0             4            0             4
2005         3         0           0               0           4             6            0             4
2001         1         5           6               0           4             2            0             7

Query to display employee name and email_id of all the employees who are working on Sunday.

SQL>    select distinct emp_name,email
       from employee_master
       where emp_id in( select emp_id from attendance   
       where suhrs>0);

EMP_NAME             EMAIL
----------------------------------------
harsha               harsha@yahoo.com
hema
rashmi               ras@www.com

Query to display the total hours worked by the employee ‘mahesh’.

SQL> select sum(a.mhrs+a.tuhrs+a.whrs+a.thhrs+a.frhrs
     +a.sahrs+a.suhrs) "Total hours worked by mahesh"
     from employee_master e, attendance a
     where e.emp_id=a.emp_id and
     e.emp_name in('mahesh');

Total hours worked by mahesh
----------------------------
                       30






Query to display the names of the employee who never attended the duty so far.

SQL>  select distinct emp_id,emp_name
     from employee_master
     where emp_id not in(select distinct emp_id from
     attendance);

   EMP_ID EMP_NAME
-------------------------------
     2003 swarna
     2004 priya
     2006 preetham
     2007 shilpa
     2008 manasa

4. Query to Delete the records of the employees who are already retiered.

SQL> delete from employee_master
      where dor<sysdate;

2 rows deleted.

5. Query to Display the names of employee who have total number of hours more than 20 hours a week.

SQL>   select distinct e.emp_name from employee_master
       e,attendance a
       where e.emp_id=a.emp_id and
      (a.mhrs+a.tuhrs+a.whrs+a.thhrs+a.frhrs
       +a.sahrs+a.suhrs)>20;

EMP_NAME
--------------
harsha
hema
mahesh

DBMS LAB Part-B 1


Create the following tables by identifying primary and foreign keys. Specify the not null property for mandatory keys.
Suppliers (supplier_no, sname, saddress, scity)
Computer_items (item_no, supplier_no,item_name,iquantity)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Create table Supplier
SQL> create table suppliers
(supplier_no number(6) primary key,
    sname varchar2(20) not null,
    saddress varchar2(30) not null,
    scity varchar2(15) not null);

Table created.

Display table fields
SQL> desc suppliers;
Name                 Null?                      Type
----------------------------------------------------------------
SUPPLIER_NO          NOT NULL          NUMBER(6)
SNAME                NOT NULL          VARCHAR2(20)
SADDRESS             NOT NULL          VARCHAR2(30)
SCITY                NOT NULL          VARCHAR2(15)

Insert values into table
SQL> insert into suppliers
     values(101,'microtech','kulur','mangalore');

1 row created.

SQL> select * from suppliers;

SUPPLIER_NO     SNAME        SADDRESS       SCITY
------------------------------------------------------------------------
    101        microtech     kulur            mangalore
    102        cats          kavoor       mangalore
    103        electrotech   lalbag       bangalore
    104        onida              bejai        mangalore
    105        samsung       PVS          bangalore

Create table computer_items
SQL> create table computer_items(
  item_no number(6) primary key,
  supplier_no number(6)references suppliers(supplier_no),
  item_name varchar2(15) not null,
  iquantity number(6) not null);

Table created.

Display table fields
SQL> desc computer_items;
Name               Null?              Type
-----------------------------------------------------
ITEM_NO           NOT NULL          NUMBER(6)
SUPPLIER_NO          NOT NULL                 NUMBER(6)
ITEM_NAME         NOT NULL          VARCHAR2(15)
IQUANTITY         NOT NULL          NUMBER(6)

Insert values into table
SQL> insert into computer_items values(
     501,101,'monitor',3);

1 row created.

SQL> select * from computer_items;

  ITEM_NO   SUPPLIER_NO     ITEM_NAME       IQUANTITY
------------------------------------------------------------------------
      501         101           monitor                 3
      502         103           keyboard                5
      503         105           mouse                   7
      504         102           pendrive                6
      506         104           floppy_disk             8
      505         103           hard disk               5
      507         102           joystick                3
      508         104           printer                 9
      509         105           scanner                 6
      510         104           ups                     9

1. Query to list item and suppliers details:

SQL> select s.supplier_no,s.sname,s.saddress,s.scity,
     c.item_name
     from suppliers s,computer_items c
     where s.supplier_no=c.supplier_no;

SUPPLIER_NO    SNAME     SADDRESS    SCITY     ITEM_NAME
--------------------------------------------------------------------------------
    101      microtech    kulur     mangalore  monitor
    103      electrotech  lalbag    bangalore  keyboard
    105      samsung      PVS       bangalore  mouse
    102      cats         kavoor    mangalore  pendrive
    104      onida        bejai     mangalore floppy_disk
    103      electrotech  lalbag    bangalore  hard disk
    102      cats         kavoor    mangalore  joystick
    104      onida        bejai     mangalore  printer            
    105      samsung      PVS       bangalore  scanner
    104      onida        bejai     mangalore  ups

2. Query to list the names of the supplier who are supplying keyboard:

SQL> select s.supplier_no,s.sname
     from suppliers   s,computer_items c
     where s.supplier_no=c.supplier_no and
     c.item_name='keyboard';

SUPPLIER_NO        SNAME
--------------------------------
    103         electrotech

3. Query to display the items supplied by ‘microtech’:

SQL> select c.item_no,c.item_name,c.iquantity
     from suppliers s,computer_items c
     where s.supplier_no=c.supplier_no and
     s.sname='microtech';

  ITEM_NO        ITEM_NAME       IQUANTITY
---------------------------------------------
    501            monitor           3

4. Query to list the items supplied by the suppliers ‘cats’ and ‘electrotech’:

SQL> select c.item_no,c.item_name,c.iquantity,s.sname
     from suppliers s,computer_items c
     where s.supplier_no=c.supplier_no and
     s.sname in('cats','electrotech');

  ITEM_NO        ITEM_NAME       IQUANTITY      SNAME
-------------------------------------------------------------------------
    502          keyboard           5        electrotech
    504          pendrive           6        cats
    505          hard disk          5        electrotech
    507          joystick           3        cats

DBMS LAB Part-A 4

Ex 4:
To create table book using SQL command to store ISBN, TITLE, PUBLISHER, CATEGORY, YEAR, PRICE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SQL> CREATE TABLE BOOK( 
   ISBN VARCHAR2(10) PRIMARY KEY,
   TITLE VARCHAR2(20) NOT NULL,
   PUBLISHER VARCHAR2(15) NOT NULL,
   CATEGORY VARCHAR2(10) NOT NULL,
   YEAR NUMBER(04) NOT NULL,
   PRICE NUMBER(8,2) NOT NULL);

Insert values into table:
INSERT INTO BOOK
VALUES(‘C01001’,’JAVA’,’MICROSOFTPRESS’,
       ’COMP SC’,2009,2000);

SQL> SELECT * FROM BOOK;

ISBN               TITLE                       PUBLISHER             CATEGORY   YEAR          PRICE
-------------------------------------------------------------------------------------------------------
C01001   JAVA                      MICROSOFT PRESS  COMP SC      2009            2000
C01002   C++                       MICRO                      COMP SC       2009            1500
CO1003   INDIAN CIVIL              SUMUKHA                  HISTORY       2011            999
C01004    ELECTRONICS            RAMAN                        PHYSICS        2006            500
C01005    LIVING ORGANISMS STROUPTOS               BIOLOGY      2010            450
C01006    INDIAN CIVIL              C.V                        CIVICS            2003            200
C01007    COA                       MICRO                      COMP SC       2009            150
C01008    FORMULAS                  MATHEMATICS        MATHS          2000            100
C01009    JAVA                      MICROSOFT PRESS COMP SC        2004           156
C01010    FORMULAS                  MATHEMATICS        MATHS           2001           250

10 rows selected.

1. List the details of the book whose publishers name start with m.

SQL> SELECT * FROM BOOK
     WHERE PUBLISHER LIKE 'M%';

ISBN         TITLE             PUBLISHER            CATEGORY    YEAR        PRICE
-----------------------------------------------------------------------------------------------
C01001    JAVA                MICROSOFT PRESS      COMP SC        2009         2000
C01002    C++                  MICRO                COMP SC        2009         1500
C01007    COA                 MICRO                COMP SC        2009         150
C01008    FORMULAS   MATHEMATICS          MATHS           2000         100
C01009    JAVA                MICROSOFT PRESS      COMP SC        2004         156
C01010    FORMULAS   MATHEMATICS          MATHS          2001          250

6 rows selected.

2. List the details of the publisher having A as second character in their name.

SQL> SELECT * FROM BOOK
     WHERE PUBLISHER LIKE '_A%';

ISBN               TITLE                       PUBLISHER             CATEGORY   YEAR          PRICE
-------------------------------------------------------------------------------------------------------
C01004    ELECTRONICS            RAMAN                       PHYSICS        2006           500
C01008    FORMULAS                  MATHEMATICS        MATHS          2000           100
C01010    FORMULAS                  MATHEMATICS        MATHS          2001           250

3. Find the books published in 2010,2011 and 2012.

SQL> SELECT * FROM BOOK
     WHERE YEAR IN(2010,2011,2012);

ISBN               TITLE                       PUBLISHER             CATEGORY   YEAR          PRICE
-------------------------------------------------------------------------------------------------------
C01001   JAVA                      MICROSOFT PRESS  COMP SC      2009            2000
C01002   C++                       MICRO                       COMP SC      2009            1500
CO1003  INDIAN CIVIL              SUMUKHA                   HISTORY      2011            999
C01005   LIVING ORGANISMS STROUPTOS                BIOLOGY      2010            450
C01007   COA                       MICRO                       COMP SC      2009            150

4. Display the book_id, title, publisher of all the books in the descending order in the year.

SQL> SELECT ISBN,TITLE,PUBLISHER FROM BOOK
     ORDER BY YEAR DESC;

ISBN                 TITLE                PUBLISHER
--------------------------------------------------------------------------
CO1003               INDIAN CIVIL         SUMUKHA
C01005               LIVING ORGANISMS       STROUPTOS
C01001               JAVA                 MICROSOFT PRESS
C01002               C++                 MICRO
C01007               COA                  MICRO
C01004               ELECTRONICS          RAMAN
C01009               JAVA                 MICROSOFT PRESS
C01006               INDIAN CIVILIZ       C.V
C01010               FORMULAS             MATHEMATICS
C01008               FORMULAS             MATHEMATICS

10 rows selected.


5. Display the details of all the books other than ‘Microsoft press’ publishers.

SQL> SELECT * FROM BOOK
     WHERE PUBLISHER NOT IN('MICROSOFT PRESS');

ISBN               TITLE                       PUBLISHER             CATEGORY   YEAR          PRICE
-------------------------------------------------------------------------------------------------------
C01002   C++                       MICRO                      COMP SC       2009            1500
CO1003   INDIAN CIVIL              SUMUKHA                  HISTORY       2011            999
C01004    ELECTRONICS            RAMAN                        PHYSICS        2006            500
C01005    LIVING ORGANISMS STROUPTOS               BIOLOGY      2010            450
C01006    INDIAN CIVIL              C.V                        CIVICS            2003            200
C01007    COA                       MICRO                      COMP SC       2009            150
C01008    FORMULAS                  MATHEMATICS        MATHS          2000            100
C01010    FORMULAS                  MATHEMATICS        MATHS           2001           250

8 rows selected.

6. Display title, price of all the books with the price more than 2000 and less than 3000 (using BETWEEN) operator.

SQL> SELECT TITLE, PRICE FROM BOOK
     WHERE PRICE BETWEEN 2000 AND 3000;

TITLE                    PRICE
---------------------------------
JAVA                      2000

DBMS LAB Part-A 3

Ex 3:
To create table client_master using SQL command to store CLIENT_NO, NAME, ADDRESS1, ADDRESS2, CITY, PINCODE, STATE, BAL_DUE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. For every client in client_master table decrease bal_due by 10%.

SQL> UPDATE CLIENT_MASTER
    SET BAL_DUE = BAL_DUE + (BAL_DUE*0.1);

       10 rows updated.

2. Update the table client_master, change the contents of the field name to ‘vijay kadam’ and the contents of the field address to ‘SCT Jay Apartment’ for the record with client_no=’C01002’.

    UPDATE CLIENT_MASTER SET
     NAME='VIJAY KADAM',
     ADDRESS1='SCT JAY APT'
     WHERE CLIENT_NO='C01002';

       1 row updated.

SQL> SELECT * FROM CLIENT_MASTER;

CLIENT      NAME        ADDRESS1          ADDRESS2   CITY      PINCODE     STATE               BAL_DUE
------------------------------------------------------------------------------------------------------------------------------
C01001      ANIS        MADI             BEJAI       UDUPI  574144      KARNARTAKA        9000

C01002     VIJAY KADAM        SCT JAY APT       NAGAR        UDUPI  671125       KERALA                   13500

C01003      GURU        SERE             KOTTARA   UPUPI   562232      KARNARTAKA       9900

C01004      DHANRAJ     KS               BEJAI           UDUPI   575003      KARNARTAKA        13500

C01005      MANOJ       PANDESHWAR        YAKKAR     UDUPI   567651      KARNARTAKA       12150

C01006      RAKSHITH    PERMUDE          BCROAD     UDUPI   575223      KARNARTAKA       16200

C01007      LIKHIN      MAROLI             BEJAI          UDUPI   567876      KARNARTAKA         11160

C01008      RAKSHAN     MALALI             SULYA        UDUPI   574144      KARNARTAKA         5000

C01009      NISHANK     POLALI             PADAV       UDUPI   564333      KARNARTAKA         17100

C01010      BHARATH     GANDHINAG        BAJPE         UDUPI   475767      GOA                            9900

         10 rows selected.

3. Add a new column name penalty number(10,2)to the table client_master.

SQL> ALTER TABLE CLIENT_MASTER ADD PENALTY NUMBER(10,2);

        Table altered.

SQL> DESC CLIENT_MASTER;

Name        Null?    Type
------------------------------------------------------
CLIENT_NO    NOT NULL    VARCHAR2(6)
NAME         NOT NULL    VARCHAR2(20)
ADDRESS1     NOT NULL    VARCHAR2(30)
ADDRESS2     NOT NULL    VARCHAR2(30)
CITY         NOT NULL    VARCHAR2(15)
PINCODE      NOT NULL    NUMBER(8)
STATE        NOT NULL    VARCHAR2(15)
BAL_DUE      NOT NULL    NUMBER(10,2)
PENALTY      NOT NULL    NUMBER(10,2)

4. Change the size of the column penalty to(8,2) in the client_master.

SQL> ALTER TABLE CLIENT_MASTER MODIFY PENALTY NUMBER(8,2);

          Table altered.

SQL> DESC CLIENT_MASTER;

Name        Null?     Type
-----------------------------------------------------
CLIENT_NO    NOT NULL   VARCHAR2(6)
NAME         NOT NULL   VARCHAR2(20)
ADDRESS1     NOT NULL   VARCHAR2(30)
ADDRESS2     NOT NULL   VARCHAR2(30)
CITY         NOT NULL   VARCHAR2(15)
PINCODE        NOT NULL   NUMBER(8)
STATE             NOT NULL   VARCHAR2(15)
BAL_DUE        NOT NULL   NUMBER(10,2)
PENALTY       NOT NULL   NUMBER(8,2)

5. Change the name of the table Client_master to client_master1.

SQL> RENAME CLIENT_MASTER TO CLIENT_MASTER1;

         Table renamed.

6. Delete all the newly created table.

SQL> DROP TABLE CLIENT_MASTER1;