60 (2)
60 (2)
60 (2)
Create tables for Client, Product, and Salesman with the attributes given, implementing
DDL commands for specifying prime attributes, non-prime attributes, foreign keys,
cardinalities, null values, constraints etc. and the data types. Implement DDL commands
for drop, alter on the tables created.
CLIENT_MASTER :
CREATE TABLE Client(
client_no VARCHAR2(6)PRIMARY KEY CHECK(client_no like '%c'),
Name VARCHAR(20)NOT NULL,
City VARCHAR(15),
Pincode NUMBER(8),
State VARCHAR(15),
BalDue NUMBER(10,2)
);
DESC Client_Master;
SALESMAN_MASTER :
CREATE TABLE Saleman(
Salesman_no VARCHAR2(6) PRIMARY KEY CHECK (Salesman_no LIKE 'S%'),
Salesman_name VARCHAR2(20) NOT NULL,
City VARCHAR2(20) NOT NULL,
Pincode NUMBER(8) NOT NULL,
State VARCHAR2(20) NOT NULL,
Sal_Amt NUMBER(8, 2) NOT NULL CHECK (Sal_Amt <> 0)
);
DESC Salesman;
SALES_ORDER :
CREATE TABLE Sales_Orde (
Order_no VARCHAR2(6) PRIMARY KEY CHECK (Order_no LIKE 'O%'),
Client_no VARCHAR2(6),
Order_date DATE,
Salesman_no VARCHAR2(6),
Dely_type CHAR(1) DEFAULT ‘F’ CHECK (Dely_type IN ('F', 'P')),
Dely_date DATE,
FOREIGN KEY (Client_no) REFERENCES Client (Client_no),
FOREIGN KEY (Salesman_no) REFERENCES Salesman(Salesman_no)
);
DESC Sales_Orde;
SALES_ORDER_DETAILS :
CREATE TABLE Sales_Orde_Details (
Order_no VARCHAR2(6),
Product_no VARCHAR2(6),
Qty_disp NUMBER(8),
Product_rate NUMBER(10, 2),
FOREIGN KEY (Order_no) REFERENCES Sales_Orde (Order_no),
FOREIGN KEY (Product_no) REFERENCES Product(Product_no)
);
DESC SALES_ORDER_DETAILS;
-- iii. Retrieve the list of names, city, and state of all clients.
SELECT Name, City, State FROM Client;
-- iv. List the various products available from the Product_Master table.
SELECT Description FROM Product;
-- vi. Find the names of salesman who have a salary equal to 3000.
SELECT Salesman_name FROM Saleman WHERE Sal_Amt = 3000;
QUESTION 2
-- iii. Change the cost price of ‘Trousers’ to Rs. 950.00 where Product No P001.
UPDATE Product SET Description = 'Trousers' WHERE Product_No = ‘P001’;
UPDATE Product SET Cost_Price = 950.00 WHERE Description = 'Trousers';
Question 4
Change the size of Sell_Price column in Product_Master to 10, 2
Question 5
Drop the column Cost_Price from Product_Master.
Question 6
Delete all salesmen from the Salesman_Master whose salaries are equal to Rs. 3500
Question 7
Delete all products from Product_Master where the quantity on hand is equal to 100.
Question 8
Delete from Client_Master where the column state holds the value ‘Tamil Nadu’.
Question 9
Change the name of the Salesman_Master table to Sman_Mast.
Question 10
Destroy the table Client_Master along with its data.