0% found this document useful (0 votes)
62 views4 pages

Subquery

Here are the responses to your questions: 1. No changes are made to the database when a SELECT statement is run. A SELECT statement is used to query and retrieve data from the database, but it does not modify any data. 2. The SELECT statement allows you to view the data in the database, but does not permanently alter the structure or contents of any tables. It provides a temporary view of the data for the user, but the database remains unchanged once the SELECT statement has finished running. 3. You can use SELECT statements to experiment with different ways of retrieving data without worrying about accidentally changing anything important. The database acts like a read-only view for SELECT statements. Any modifications would require statements like INSERT, UPDATE

Uploaded by

DGreatWannie
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
62 views4 pages

Subquery

Here are the responses to your questions: 1. No changes are made to the database when a SELECT statement is run. A SELECT statement is used to query and retrieve data from the database, but it does not modify any data. 2. The SELECT statement allows you to view the data in the database, but does not permanently alter the structure or contents of any tables. It provides a temporary view of the data for the user, but the database remains unchanged once the SELECT statement has finished running. 3. You can use SELECT statements to experiment with different ways of retrieving data without worrying about accidentally changing anything important. The database acts like a read-only view for SELECT statements. Any modifications would require statements like INSERT, UPDATE

Uploaded by

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

subquery

A SELECT statement that provides a set of rows for processing. Its syntax is like
the select_into_statement without the INTO clause. See "SELECT INTO Statement".

Direction: Write the PL/SQL code on the space provided after each questions.

1. Create a table name as: EMPLOYEE_RECORD with the following column as


shown below:
ID FIRSTNAM LASTNAM EMAIL JOB_ID SALARY DEPT_ID
E E
Number( Varchar(10) Varchar(1 Varchar(1 Varchar1 Number( Number(
6) 0) 5) 5 6) 6)
PK NOT NULL

2. Insert the following Data as shown in the table below:


ID FIRSTNAME LASTNAM EMAIL JOB_ID SALARY DEPT_ID
E
100 Steven King Sking Ad_pres 240000 10
101 Nena Kochar Nkochar Ad_vp 17000 20
102 Lex De haan Ldehaan Ad_vp 17000 50
103 Alexander Hunold Ahunold It_prog 9000 60
104 Bruce Ernst Bernst It_prog 6000 80
107 Diana Lorentz Dlorentz St_man 5800 90
124 Kevin Mourgos Kmourgos St_clerk 5800 110
141 Trina Rajs Trajs St_clerk 5800 190
142 Curtis Davias Cdavias St_clerk 5800 191
143 Randal Matos Rmatos St_man 4200 195

3. Add new column name as ADDRESS data type char size 20.
4. After you add a new column address view now the table? What happen to the
addresses of all old employees? Explain the reason why?
5. Add new record as shown below:
10 JULY SORIANO MSORIANO TEACHER 2600 8 BRGY.PAMBUAN GAPAN
5 0

 Is inserting a new record in No.5 is possible? Why and why not? Explain the
reason why?
6. Add again a new record as shown below:
105 ARRIANE SALAMAT ASALAMAT TEACHER 2600 80 BRGY.MANGINO

 Is inserting a new record in No.6 is possible? Why and why not? Explain the
reason why?
7. Add again a new record as shown below:
10 RAYCHELOU VALENCIA RVALENCIA DEAN 50000 80 CANIOGAN ST. DR. SIXTO
6 BLDG. PASIG

 Is inserting a new record in No. 8 is possible? If not perform some


modification on table structure in order to insert the record of Ms. Valencia.

Note: For succeeding activity: make sure to view you table and study it content.
8. All employees that having a salary of 5800 should be assigned in one dept_id 90,
update their departments to 90.
9. Trina got married, after her leave Ms. Trina ask you to update her record in the
database from RAJS to DE LEON.
10. After serving the company for three year Randal got promoted as the newest
ad_pres and with a new salary of 250000. Update his record using one SQL only.
11. Since Mr. Randal replace the position of Mr. Steven, delete the record of Mr.
Steven since he is no longer connected to the company.
12. All employees are given an additional 2% increase in their salaries. Create an
SQL statement that would change the employees’ salaries with additional 10%.
Note: Use rows with the same values in order to limit the number of query to be
use.
13. Email address is not being use, and save space you have to delete the said
column.
14. Select the table now and draw the final output after you perform the DDL and
DML statements.
15. What will happen if the accidentally type DELETE * FROM EMPLOYEES without
issuing WHERE condition?
SELECT 
Purpose

Use a SELECT statement or subquery to retrieve data from one or more tables, object tables, views,
object views, or materialized views.

If part or all of the result of a SELECT statement is equivalent to an existing materialized view, then
Oracle Database may use the materialized view in place of one or more tables specified in
the SELECT statement. This substitution is called query rewrite. It takes place only if cost
optimization is enabled and the QUERY_REWRITE_ENABLED parameter is set to TRUE. To determine
whether query write has occurred, use the EXPLAIN PLANstatement.

Direction: Perform the following by applying SELECT statement. Below is the given table and its structure.
Before you continue make sure you created the table and inserted the correct information as shown below.

Table Name: PARTS


PARTNUM DESCRIPTION ONHAND CLASS WAREHOUS PRICE
E
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 KEY NULL
TYPE/SIZE
PARTNUM CHAR – 4 PRIMARY NO
DESCRIPTION VARCHAR – 20 NO
ONHAND NUMBER – 6 YES
CLASS CHAR – 5 YES
WAREHOUSE NUMBER – 6 YES
PRICE NUMBER – 6 YES

1. Create a report displaying all rows and columns.


2. Create a report by eliminating the duplicate rows for column class and warehouse.
3. Create a report specifying only the column PRICE, ONHAND and DESCRIPTION.
4. Create a report that will add 10% increase in PRICE. List only the column DESCRIPTION, CLASS
and PRICE.
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.
6. Create a report that will rename the column DESCRIPTION to TITLE, PARTNUM to ID and
ONHAND to STOCK.
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