0% found this document useful (0 votes)
76 views

Online Education Laboratory Exercise

The document provides instructions for 10 tasks involving running SQL queries on a PARTS database table to produce various reports and modify the table structure. The tasks include selecting specific columns, modifying data values, renaming columns, combining columns, and identifying unique values. The SELECT statement is used to query the database and produce the reports, but does not permanently change the underlying database structure.

Uploaded by

William Zenz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Online Education Laboratory Exercise

The document provides instructions for 10 tasks involving running SQL queries on a PARTS database table to produce various reports and modify the table structure. The tasks include selecting specific columns, modifying data values, renaming columns, combining columns, and identifying unique values. The SELECT statement is used to query the database and produce the reports, but does not permanently change the underlying database structure.

Uploaded by

William Zenz
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Course Code Type Course Code Here

Database Management System


Description
1
College / Department:
LabExer No. 002
Online Education
Laboratory Exercise Page 1 of 1

Direction:
 Copy and paste the PARTS table
 Copy and paste the PL/SQL code on the space provided after each questions.
Table Name: PARTS
PARTNUM DESCRIPTION ONHAND CLASS WAREHOUSE PRICE
AT94 IRON 50 HW 3 2495
BVO6 HOME GYM 45 SG 2 79495
CD52 MICROWAVE OVEN 32 AP 1 165
DL71 CORDLESS DRILL 21 HW 3 12995
DR93 GAS RANGE 21 AP 2 495
DW11 WASHER 12 AP 3 399
FD21 STAND MIXER 22 HW 3 159
KL62 DRYER 12 AP 1 349
KT03 DISHWASHER 8 AP 3 595
KV29 TREADMILL 9 SG 2 1390

PARTS structure
COLUMN NAME DATA TYPE/SIZE KEY NULL
PARTNUM CHAR – 4 PRIMARY NOT NULL
DESCRIPTION VARCHAR – 20 NOT NULL
ONHAND NUMBER – 6
CLASS CHAR – 5
WAREHOUSE NUMBER – 6
PRICE NUMBER – 6

1. Create a report displaying all rows and columns.


PARTNUM DESCRIPTION ONHAND CLASS WAREHOUS PRICE
E
AT94 IRON 50 HW 3 2495
BV06 HOME GYM 45 SG 2 79495
CD52 MICROWAVE 32 AP 1 165
OVEN
DL71 CORDLESS 21 HW 3 12995
DRILL
DR93 GAS RANGE 21 AP 2 495
DW11 WASHER 12 AP 3 399
FD21 STAND 22 HW 3 159
MIXER
KL62 DRYER 12 AP 1 349
KT03 DISHWASHE 8 AP 3 595
R
KV29 TREADWILL 9 SG 2 1390

2. Create a report by eliminating the duplicate rows for column class and warehouse.
PARTNUM DESCRIPTION ONHAND CLASS WAREHOUSE PRICE
KL62 DRYER 12 AP 1 349
DR93 GAS RANGE 21 AP 2 495
KT03 DISHWASHER 8 AP 3 595
FD21 STAND 22 HW 3 159
MIXER
KV29 TREADMILL 9 SG 2 1390

3. Create a report specifying only the column PRICE, ONHAND and DESCRIPTION.
PRICE ONHAND DESCRIPTION
2495 50 IRON
79495 45 HOME GYM
165 32 MICROWAVE OVEN
12995 21 CORDLESS DRILL
495 21 GAS RANGE
399 12 WASHER
159 22 STAND MIXER
349 12 DRYER

4. Create a report that will add 10% increase in PRICE. List only the column DESCRIPTION, CLASS and
PRICE.
DESCRIPTION CLASS PRICE
IRON HW 2744.5
HOME GYM SG 87444.5
MICROWAVE OVEN AP 181.5
CORDLESS DRILL HW 14294.5
GAS RANGE AP 544.5
WASHER AP 438.9
STAND MIXER HW 174.9
DRYER AP 383.9
DISHHWASHER AP 654.5
TRTEADMILL SG 1529.0

5. Create a report that will deduct 5 from ONHAND, multiply 5 in WAREHOUSE, after getting the value
on both ONHAND and WAREHOUSE add their data: as shown below:
ONHAND - 5 + 5 * WAREHOUSE
Note that you have to force the Oracle to prioritize first the Subtraction over Multiplication. List only the
column DESCRIPTION, ONHAND and WAREHOUSE.

Select DESCRIPTION, ONHAND-5 AS NEW_ONHAND, WAREHOUSE*5 AS


NEW_WAREHOUSE, (ONHAND-5) + (WAREHOUSE*5) as ONHAND_WAREHOUSE from parts;

DESCRIPTION NEW_ONHAND NEW_WAREHOUSE ONHAND_WAREHOUSE


IRON 45 15 60
HOME GYM 40 10 50
MICROWAVE 27 5 32
OVEN
CORDLESS DRILL 16 15 31
GAS RANGE 16 10 26
WASHER 7 15 22
STAND MIXER 17 15 32
DRYER 7 5 12
DISHWASHER 3 15 18
TREADMILL 4 10 14

6. Create a report that will rename the column DESCRIPTION to TITLE, PARTNUM to ID and
ONHAND to STOCK.
ALTER TABLE parts RENAME COLUMN DESCRIPTION to TITLE;ALTER TABLE parts
RENAME COLUMN PARTNUM to ID;ALTER TABLE parts RENAME COLUMN ONHAND to
STOCK;select * from parts;

ID TITLE STOCK CLASS WAREHOUSE PRICE


AT94
BV06
CD52
DL71
DR93
DW11
FD

7. Create a report the will merge the column CLASS and PRICE rename the COLUMN as “CLASS
PRICE”.
8. Create a report that will combine the column PARTNUM and DESCRIPTION put a literal character
string “belongs to” in between the two columns then rename the column as “NUMBER TITLE”. Note
put space before and after the character literal string to avoid no spaces in the report.
9. Create a report that will display the unique value for WAREHOUSE rename the column as “No. of
Available Warehouse”.
10. What is the help of SELECT statement? Is there any permanent made in the database once the user uses
different SELECT.

You might also like