0% found this document useful (0 votes)
42 views9 pages

Dbms Exp3b

The document discusses implementing data manipulation language (DML) commands like INSERT, UPDATE, DELETE, and SELECT in PostgreSQL/MySQL. It includes creating sample tables, inserting data, and performing various queries on the tables including retrieving data, updating records, and deleting records based on conditions.

Uploaded by

Nishant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views9 pages

Dbms Exp3b

The document discusses implementing data manipulation language (DML) commands like INSERT, UPDATE, DELETE, and SELECT in PostgreSQL/MySQL. It includes creating sample tables, inserting data, and performing various queries on the tables including retrieving data, updating records, and deleting records based on conditions.

Uploaded by

Nishant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Second Year Computer Engineering Database Management System

SE Computer (B) Roll number : 9629


Experiment no. : 3 (part 2) Date :
Academic Term :Jan-April 2023
Aim : To implement data manipulation language (DML) commands
Tool Used : PostgreSQL/MYSQL
Related Course outcome: Students should be able to
Write queries in SQL to retrieve any type of information from a data base.

Rubrics for assessment of Experiment:


Indicator Poor Average Good
Timeliness One or More than
● Maintains assignment Assignment Maintains
One week late (1-
not done (0) deadline (3)
deadline (3) 2)
Completeness and neatness
● Complete all parts of < 80% complete 100%
N/A
(1-2) complete (3)
assignment(3)
Originality Assignment
● Extent of plagiarism(2) Copied it from
At least few has been
questions have solved
someone
been done without completely
else(0)
copying(1) without
copying (2)
Knowledge Unable to
● In depth knowledge of the Unable to answer 1 Able to answer
answer 2
question (1) 2 questions (2)
assignment(2) questions(0)

Assessment Marks :

Timeliness (2)
DDL/DML/TCL (2)
Applies Appropriate SQL /
PLSQL (3)
Knowledge (2)
Total (10)

Total : (Out of 10)


Second Year Computer Engineering Database Management System

Theory:
Data Manipulation Language
A Data Manipulation Language enables programmers and users of the database to retrieve insert, delete
and update data in a database. e.g. INSERT, UPDATE, DELETE, SELECT.

INSERT:
INSERT statement adds one or more records to any single table in a relational database.
INSERT INTO tablename VALUES (expr1,expr2……..);

UPDATE:
UPDATE statement that changes the data of one or more records in a table. Either all the rows can be
updated, or a subset may be chosen using a condition.
UPDATE table_name SET column_name = value [, column_name = value ...] [WHERE condition]

DELETE:
DELETE statement removes one or more records from a table. A subset may be defined for deletion
using a condition, otherwise all records are removed.
DELETE FROM tablename WHERE condition
Second Year Computer Engineering Database Management System

Implementation:
1. Create following tables:
Table name : client_master

Column Name Data type Size


Client_no varchar 6
Client_name Varchar 20
Address Varchar 30
City Varchar 15
Pincode Numeric 8
State Varchar 15
Due_bal Numeric 10,2
Second Year Computer Engineering Database Management System

Table name: Product_master


Column Name Data type Size
product_no varchar 6
description varchar 15
Profit_percent numeric 4,2
Unit_measure varchar 10
Qty_on_hand varchar 8
Reorder_level numeric 8
Sell_price numeric 8,2
Cost_price numeric 8,2

2. Insert following data in client_master and product master.


Client_master
client_no client_name address City pincode state Bal_due
C001 Sam Kothrud Pune 411077 Maharastra 10000.23
C002 John Kurla Mumbai 400087 Maharastra 50000.55
C003 Jack Kishan Gandhi 400055 Gujrat 25000.93
Nagar nagar
C004 Ann Charminar Hydrabad 400090 Andhra 77000.00
Pradesh
C005 Piter Bandra Mumbai 400045 maharstra 88000.23
C006 Nick Vasai mumbai 400077 Maharastra 10000.23

Product_master

product description Profit_perc Unit_meas Qty_on_h Reorder_ Sell_price Cost_price


_no ent ure and level
p1 Laptop 30.12 Low 1200 13000 60000.23 50000.34
p2 Refrigerato 30.92 Medium 4354 42255 42423.24 35000.55
r
p3 Hard disk 10.00 High 5678 8723 3500.00 2500.00
p4 Mixture 40.12 Low 2535 44000 10000.23 8000.34
p5 washing 35.12 High 9000 90000 40000.9 28000.90
machine 9

3. Find out the names of all clients


4. Retrieve the entire contents of the client_master table.
5. Retrieve the list of names and cities of all the clients
6. List the various products available from the product_master table
7. List all the clients who are located in mumbai.
8. Change the city of client_no C001 to mumbai
9. Change the bal_due of client_no C005 to Rs. 10000
10. Change the cost price of 'hard disk' to Rs. 3000
11. Delete all the products from product_master where the qty_on_hand is less than 100
12. Delete from client_master where the column state holds the value 'Andhra pradesh'
Second Year Computer Engineering Database Management System

Post Lab questions:


1. What is Data Dictionary?
2. What is Schema?
3. What are different data types in SQL?

IMPLEMENTATION

1.Code:-Create table client_master3(client_no varchar(6), Client_name varchar(20),Address


varchar(30) ,city varchar(15), pincode Numeric(8), State varchar (15), Due_bal Numeric(10));
output:-

Code-
Create table Product_master3(
Product_no varchar(6),
desciption varchar(15),
profit_percent numeric(4,2),
unit_measure varchar(10),
qty_on_hand varchar(8),
Recoder_level numeric (8),
sell_Price numeric(8,2),
Cost_price numeric(8,2)
);
output:-
Second Year Computer Engineering Database Management System

2.Code:-
INSERT INTO Client_master3 VALUES ('C001','SAM','KOTHRUD','PUNE',411077,'MAHARASHTRA',10000.23);
INSERT INTO Client_master3 VALUES ('C002','JOHN','KURLA','MUMBAI',400087,'MAHARASHTRA',50000.55);
INSERT INTO Client_Master3 VALUES ('C003','JACK','KISHAN NAGAR','GANDHI',400055,'GUJRAT',25000.93);
INSERT INTO Client_Master3 VALUES
('C004','ANN','CHARMINAR','HYDERABAD',400090,'ANDHRA PRADESH',77000.00);
INSERT INTO Client_Master3 VALUES ('C005','PITER','BANDRA','MUMBAI',400045,'MAHARASHTRA',88000.23);
INSERT INTO Client_Master3 VALUES ('C006','NICK','MUMBAI','MUMBAI',400077,'MAHARASHTRA',100000.23);

output:-

code:-
INSERT INTO Product_master3 VALUES ('P1','LAPTOP',30.12,'LOW',1200,13000,60000.23,50000.34);
INSERT INTO Product_master3 VALUES ('P2','REFRIGERATOR',30.92,'MEDIUM',4354,42255,4243.24,35000.55);
INSERT INTO Product_master3 VALUES ('P3','HARD DISK',10.00,'HIGH',5678,8723,10000.23,2500.00);
INSERT INTO Product_master3 VALUES ('P4','MIXTURE',40.12,'LOW',9000,44000,40000.99,8000.34);
INSERT INTO Product_master3 VALUES ('P5','WASHING MACHINE',35.12,'HIGH',9000,90000,40000.99,280000.90);
Output:-

3.Code:-
SELECT Client_name FROM Client_Master3
output:-
Second Year Computer Engineering Database Management System

4.Code:- SELECT * FROM client_master3


Output;-

5. Code:-

SELECT Client_name,city FROM Client_Master3

output:

6.Code-
select * from Product_master3
output:-
Second Year Computer Engineering Database Management System

7.Code:-
Select Client_name from client_master3 where city ='MUMBAI';
output:-

8.Code:-
update client_master3 set city='MUMBAI' where client_no='C001';

output:-

9.Code-update client_master3 set Due_bal=10000 where client_no='C005';


Output-

10.Code:-update Product_master3 set Cost_price=3000 where desciption='HARD DISK';


output:-

11.Code:-
Second Year Computer Engineering Database Management System

DELETE FROM product_master3 WHERE qty_on_hand<'100'


output:-

12.Code:-
Delete from Client_master3 Where state='ANDHRA PRADESH'
Output:-

You might also like