0% found this document useful (0 votes)
11 views3 pages

Lab 3

The document contains SQL commands for managing data in two schemas: 'company' and 'sales_management'. It includes operations such as inserting, updating, and deleting records for employees, departments, projects, customers, items, and invoices. The commands demonstrate various database management tasks, including salary adjustments and inventory updates.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Lab 3

The document contains SQL commands for managing data in two schemas: 'company' and 'sales_management'. It includes operations such as inserting, updating, and deleting records for employees, departments, projects, customers, items, and invoices. The commands demonstrate various database management tasks, including salary adjustments and inventory updates.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Id - 202301072

Ques 1) In company schema

INSERT INTO employee (ssn, fname, minit, lname, bdate, address, sex, salary, superssn, dno)
VALUES ('123234345', 'Pankaj', NULL, 'Jain', '1975-01-13', NULL, NULL, NULL, NULL, 5);

UPDATE employee
SET superssn = '123234345'
WHERE ssn = '123456789';

INSERT INTO department (dname, dno, mgrssn, mgrstartdate)


VALUES ('Marketing', 11, '888665555', '2005-05-11');

INSERT INTO employee (ssn, fname, minit, lname, bdate, address, sex, salary, superssn, dno)
VALUES ('777888999', 'Amit', NULL, 'Shah', NULL, NULL, NULL, NULL, NULL, 11),
('666555444', 'Rajesh', NULL, 'Gupta', NULL, NULL, NULL, NULL, NULL, 11);

INSERT INTO project (pname, pno, plocation, dno)


VALUES ('ERP Implementation', 9, NULL, 11);

INSERT INTO works_on (essn, pno, hours)


VALUES ('777888999', 9, 40),
('666555444', 9, 40);

UPDATE employee
SET salary = salary * 1.08
WHERE dno = 5;

DELETE FROM employee


WHERE ssn = '123234345';

Q2) in sales_managment schema


INSERT INTO sales_management.customer (cust_id, name, city, state, pin, email)
VALUES
(101, 'Anish', 'Bhopal', 'Madhya Pradesh', '560001', '[email protected]'),
(102, 'Dev', 'Pune', 'Maharashtra', '232301', '[email protected]'),
(103, 'Tom', 'Diu', 'Gujarat', '384523', '[email protected]'),
(104, 'Riya', 'Bengaluru', 'Karnatak', '768787', '[email protected]'),
(105, 'Harsh', 'Jaipur', 'Rajasthan', '654001', '[email protected]');

1
Id - 202301072

INSERT INTO sales_management.items (item_code, item_name, category_id, saleprice,


qty_in_stock, reorderlevel, averagepurchaseprice)
VALUES
(11100, 'Milk', 1, 25, 50, 1, 23),
(11101, 'Cheese', 1, 30, 20, 1, 26),
(11102, 'Lassi', 1, 12, 50, 2, 11),
(11103, 'Apple', 2, 15, 100, 1, 10),
(11104, 'Tomato', 2, 7, 120, 1, 6),
(11105, 'Earphone', 3, 50, 35, 3, 42),
(11106, 'Charger', 3, 150, 5, 3, 125),
(11107, 'Mobile', 3, 10000, 3, 3, 7900),
(11108, 'T-shirt', 4, 250, 25, 2, 220),
(11109, 'Purse', 4, 100, 40, 3, 85);

INSERT INTO sales_management.invoice (invno, invdate, customerid)


VALUES
(1, '2019-12-11', 104),
(2, '2020-02-21', 102),
(3, '2019-08-15', 101),
(4, '2019-11-30', 105),
(5, '2019-03-31', 103);

INSERT INTO sales_management.invoicedetails (invno, itemcode, qty, rate)


VALUES
(1, 11108, 2, 500),
(1, 11109, 1, 100),
(2, 11101, 2, 60),
(2, 11102, 3, 36),
(2, 11100, 1, 25),
(2, 11104, 5, 35),
(3, 11105, 1, 50),
(3, 11106, 1, 150),
(4, 11108, 1, 250),
(4, 11109, 1, 100),
(4, 11101, 2, 60),
(4, 11102, 3, 36),
(5, 11105, 2, 100),
(5, 11106, 1, 150),
(5, 11107, 1, 10000);

UPDATE sales_management.items
SET saleprice = 15
WHERE item_code = 11102;

2
Id - 202301072

UPDATE sales_management.items
SET qty_in_stock = qty_in_stock + 10;

UPDATE sales_management.items
SET qty_in_stock = qty_in_stock - 5
WHERE category_id = 2;

DELETE FROM sales_management.items


WHERE item_code = 11101;

DELETE FROM sales_management.customer


WHERE cust_id = 101;

DELETE FROM sales_management.invoicedetails


WHERE invno IN (SELECT invno FROM sales_management.invoice WHERE invdate = '2022-
12-11');

DELETE FROM sales_management.invoice


WHERE invdate = '2022-12-11';

You might also like