(a) To fetch garments of size 'L', we use the
SELECT statement with a
WHERE clause.
It ensures only those records are fetched where SIZE is equal to 'L'.
SELECT GNAME FROM GARMENT WHERE SIZE = 'L';
This command retrieves the names of garments available in L size: Jeans, Trousers, and Ladies Top.
(b) To update the COLOUR of garment with GCODE 115, use the
UPDATE statement.
It targets the exact row using the GCODE field.
UPDATE GARMENT SET COLOUR = 'Orange' WHERE GCODE = 115;
This statement changes the COLOUR of Trousers (GCODE 115) to Orange.
(c) The
INSERT INTO statement adds a new row to the GARMENT table.
We provide values in the same order as the columns in the table.
INSERT INTO GARMENT (GCODE, GNAME, SIZE, COLOUR, PRICE)
VALUES (117, 'Kurta', 'M', 'White', 1000);
This command adds a new garment record named Kurta to the table.
(d) To remove a column from a table in SQL, we use the
ALTER TABLE statement with
DROP COLUMN.
ALTER TABLE GARMENT DROP COLUMN COLOUR;
This command removes the COLOUR column and all its associated data from the GARMENT table.