Subquery
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.
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
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.
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