DBMS Assignment 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

CLASS: SYMCA ROLL NO.

:06
SUB :DBMS LAB DIV : A

BHARATI VIDYAPEETH’S
INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY,
NAVI MUMBAI

MCA SEM III


DBMS Practical
Assignment 1

Topic: SQL commands for DDL, DML and DQL Date:

Q1.

Create table Customers


(CUST_ID, CUST_NAME, ADDRESS, CITY, STATE, PINCODE,NATIONALITY)
Q1) A)CREATE TABLE Customers(CUST_ID NUMBER(10),
CUST_NAME VARCHAR2(30),
ADDRESS VARCHAR2(30),
CITY VARCHAR2(15),
STATE VARCHAR2(15),
PINCODE NUMBER(10),
NATIONALITY VARCHAR2(15)
);
OUTPUT :

DESCRIBE Customers;
CLASS: SYMCA ROLL NO.:06
SUB :DBMS LAB DIV : A

Create table Item


(ITEM_ID, DESCRIPTION,UNIT_PRICE,QTY_ON_HAND, SELLPRICE)
B) CREATE TABLE Item(ITEM_ID NUMBER(10),

DESCRIPTION VARCHAR2(30),
UNIT_PRICE NUMBER(20),
QTY_ON_HAND NUMBER(15),
SELL_PRICE NUMBER(20)
);
DESCRIBE Item;
OUTPUT :

Create table Salesman


(SALESMAN_ID, NAME,PH_NO, CITY, PINCODE, STATE,NATIONALITY ,SALEAMT)
B) CREATE TABLE Salesman(SALESMAN_ID NUMBER(10),

NAME VARCHAR2(30),
PH_NO NUMBER(20),
CLASS: SYMCA ROLL NO.:06
SUB :DBMS LAB DIV : A
CITY VARCHAR2(15),
PINCODE NUMBER(10),
STATE VARCHAR2(15),
NATIONALITY VARCHAR2(15),
SALEAMT NUMBER(20)
);

DESCRIBE Salesman;
OUTPUT :

Q2. Insert data into their respective tables

INSERT INTO Customers


VALUES(1,'ASHOK','ABC','Nagpur','Maharashtra',000001,'Indian');
INSERT INTO Customers
VALUES(2,'BIRLA','BCD','Mumbai','Maharashtra',000002,'Indian');
INSERT INTO Customers
VALUES(3,'CAJETAN','CDE','Pune','Maharashtra',000003,'Indian');
INSERT INTO Customers
CLASS: SYMCA ROLL NO.:06
SUB :DBMS LAB DIV : A
VALUES(4,'DIMPLE','DEF','Nagpur','Maharashtra',700405,'Indian');
INSERT INTO Customers
VALUES(5,'ELLIE','EFG','Nagpur','Maharashtra',700987,'Indian');

SELECT * FROM Customers;


OUTPUT :

Data Entry For Item


INSERT INTO Item VALUES(1,'FLASHDRIVES',250,200,400);
INSERT INTO Item VALUES(2,'CDROM',100,100,200);
INSERT INTO Item VALUES(3,'WIRELESS_MOUSE',300,100,450);
CLASS: SYMCA ROLL NO.:06
SUB :DBMS LAB DIV : A
INSERT INTO Item VALUES(4,'WIRELESS_SPEAKER',300,100,450);
INSERT INTO Item VALUES(5,'HDD1034',300,100,450);

SELECT * FROM Item;

OUTPUT :
CLASS: SYMCA ROLL NO.:06
SUB :DBMS LAB DIV : A

Data Entry for Salesman :

INSERT INTO Salesman


VALUES(1,'ASHOK',1122334455,'Mumbai',000001,'Maharashtra','Indian',10000);
INSERT INTO Salesman
VALUES(2,'BIRLA',1122334466,'Navi_Mumbai',000002,'Maharashtra','Indian',5000);
INSERT INTO Salesman
VALUES(3,'CAJETAN',1122334477,'Pune',000003,'Maharashtra','Indian',6000);
INSERT INTO Salesman
VALUES(4,'DIMPLE',1122334488,'Pune',000004,'Maharashtra','Indian',4000);
INSERT INTO Salesman
VALUES(5,'ELLIE',1122334499,'Nagpur',000005,'Maharashtra','Indian',150000);

SELECT * FROM Salesman;


OUTPUT :
7|Page
Q3.

Exercise on retrieving records from a table

a) Retrieve the list of names, phone number and city of all the salesman

OUTPUT :

b) Retrieve information about all the customers available in ‘Nagpur’ and having the
pincode 700405 or 700987

OUTPUT :

c) List all the salesman located in MUMBAI or Navi Mumbai.

OUTPUT :

d) Find out the item with description ‘CDROM’ and ‘HDD1034’

OUTPUT :
8|Page
e) Find out the Salesman who stay in ‘Pune’ and have a sale amount greater than 5000

OUTPUT :

f) List all the Products whose Sellprice value is equal to 450

9|Page
SYMCA DBMS LAB ASSIGNMENT NO : 01 Div: A Roll No : 02

Q4) Updating Records


a) INSERT INTO Customers
VALUES(6,'FATIMA','Belapur','Belapur','Andhra',100004,'Indian');
INSERT INTO Customers VALUES(7,'GANGA','Vashi','Vashi','Telangana',100005,'Indian');
UPDATE Customers SET CITY='Nagpur',STATE='Maharashtra' WHERE
ADDRESS='Belapur' OR ADDRESS='Vashi';
OUTPUT :

10 | P a g e
b) INSERT INTO Item VALUES(6,'KEYBOARD',100,20,100);
UPDATE Item SET
QTY_ON_HAND=50,SELL_PRICE=SELL_PRICE+0.1*SELL_PRICE WHERE
DESCRIPTION='KEYBOARD';
OUTPUT :

Q5) Altering Table Structure


a) ALTER TABLE Salesman DROP COLUMN NATIONALITY;
ALTER TABLE Customers DROP COLUMN NATIONALITY;
OUTPUT :

11 | P a g e
12 | P a g e
b)ALTER TABLE Item RENAME COLUMN DESCRIPTION TO PRODUCT;
OUTPUT :

c) ALTER TABLE Customers ADD DATE_OF_BIRTH varchar2(15);


OUTPUT :

13 | P a g e
Q6) Deleting records
a) DELETE FROM Customers WHERE CITY='Nagpur';

OUTPUT :

b) INSERT INTO Salesman


VALUES(6,'FATIMA',1122334400,'Nagpur',000006,'Maharashtra',1000);
DELETE FROM Salesman WHERE SALEAMT>5000 OR SALEAMT<2000;
OUTPUT :

c) INSERT INTO Item VALUES(7,'FLOPPYDISK',300,0,450);

DELETE FROM Item WHERE QTY_ON_HAND=0;

14 | P a g e
OUTPUT :

7) Renaming The Table


ALTER TABLE Customers RENAME TO cust_details;
OUTPUT :

15 | P a g e
8) Delete The Table With All Its Contents
OUTPUT :

9) Truncate Table
TRUNCATE TABLE Item;
OUTPUT :

16 | P a g e
17 | P a g e

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy