Professional Documents
Culture Documents
Creating Tables
1. Creating the table Client_Master
Query:
CREATE TABLE Client_Master(
Client_no VARCHAR2(6) PRIMARY KEY CHECK(Client_no LIKE 'C%'),
Name VARCHAR2(20) NOT NULL,
City VARCHAR2(15),
Pincode NUMBER(8),
State VARCHAR2(15),
BalDue NUMBER(10,2));
Output:
Output:
Output:
Output:
3. Inserting Values into Salesman_Master
Query:
INSERT INTO Salesman_Master VALUES('S1','John', 'Kolkata', 700091, 'West
Bengal', 4000);
INSERT INTO Salesman_Master VALUES('S2','Joey', 'Chennai', 357353, 'Tamil
Nadu', 3000);
INSERT INTO Salesman_Master VALUES('S3','Ross', 'Bangalore', 575735,
'Karnataka', 3500);
INSERT INTO Salesman_Master VALUES('S4','Chandler', 'Mumbai', 787354,
'Maharashtra', 3000);
INSERT INTO Salesman_Master VALUES('S5','Zeke', 'New Delhi', 873734, 'New
Delhi', 3500);
Output:
Output:
Queries
1. Exercise on retrieving records from a table
a. Find out the name of all clients
Query:
SELECT Name FROM Client_Master;
Output:
Output:
Output:
Output:
Output:
g. Show the details of Product_Master according to Cost_Price in Descending
Order
Query:
SELECT * FROM Product_Master ORDER BY Cost_Price DESC;
Output:
Output:
Output:
2. Exercise on updating records in a table
a. Change the city of client no ‘C001’ to ‘Bangalore’.
Query:
UPDATE Client_Master SET City = ‘Bangalore’ WHERE Client_no =
‘C001’;
SELECT * FROM Client_Master;
Output:
Output:
Output:
Output:
Output:
6. Delete all salesmen from the Salesman_Master whose salaries are equal to Rs. 3500.
Query:
DELETE FROM Salesman_Master WHERE Sal_Amt=3500;
SELECT * FROM Salesman_Master;
Output:
7. Delete all products from Product_Master where the quantity on hand is equal to 100.
Query:
DELETE FROM Product_Master WHERE Qty_on_Hand = 100;
SELECT * FROM Product_Master;
Output:
8. Delete from Client_Master where the column state holds the value ‘Tamil Nadu’.
Query:
DELETE FROM Client_Master WHERE State= ‘Tamil Nadu’;
SELECT * FROM Client_Master;
Output:
Output:
Output: