Queyquep MIDTERM PRACTICESET8

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

COLLEGE OF INFORMATION TECHNOLOGY EDUCATION 

ITE 014 - Information Management 


Midterm 
 
Name: Queyquep, Andre Nathan C.  Date: Mar 6 2020
Program/Section: BSIT/IT22FB5  Instructor: Ms. Paula Jean Castro
Assessment Task: Midterm Practice Set 8

Instructions:

● Study the lecture files provided from FILES > Finals > Finals Lecture 3
● Perform the examples provided and solve the hands-on problems in Practice Set 8
(Practice08 pdf file)
● Use your newly created virtual machine
● Connect to the SQL Plus using your assigned ORA user. Example
ora1/ora1@pdbINITIALS (Ex. pdbpjmc). Make sure you were able to run the setup.sql
script in this pdbINITIALS.
● Answer all the questions provided
● Analyze and perform the problems below and answer it to the best of your ability
● Write your complete answer in a Short Bond Paper and provide softcopy documentation.
● Include screen shots of your complete SQL Statements and the result/s (for hands-on
problems)
● Include a brief description/caption of each image
● There must be a name for each image (see example below)
● Save your work as DOC pr PDF (Ex. CASTRO_MIDTERM_PRACTICESET8.DOC)

Insert data into the MY_EMPLOYEE table.

1. Run the statement in the lab8_1.sql script to build the MY_EMPLOYEE table that will be used
for the lab.

CREATE TABLE my_employee


(id NUMBER(4) CONSTRAINT my_employee_id_nn NOT NULL,
last_name VARCHAR2(25),
first_name VARCHAR2(25),
userid VARCHAR2(8),
salary NUMBER(9,2));
2. Describe the structure of the MY_EMPLOYEE table to identify the column names.

DESC my_employee
3. Add the first row of data to the MY_EMPLOYEE table from the following sample data. Do not
list the columns in the INSERT clause.

ID LAST_NAME FIRST_NAME USERID SALARY

1 Patel Ralph rpatel 895


2 Dancs Betty bdancs 860
3 Biri Ben bbiri 1100
4 Newman Chad cnewman 750
5 Ropeburn Audrey aropebur 1550

4. Populate the MY_EMPLOYEE table with the second row of sample data from the preceding
list.
This time, list the columns explicitly in the INSERT clause.

INSERT INTO my_employee (id, last_name, first_name,


userid, salary)
VALUES (2, ’Dancs’, ’Betty’, ’bdancs’, 860);
5. Confirm your addition to the table.

SELECT *
FROM my_employee;
ID LAST_NAME FIRST_NAME USERID SALARY
1 Patel Ralph rpatel 895
2 Dancs Betty bdancs 860
3 Biri Ben bbiri 1100
4 Newman Chad cnewman 750
5 Ropeburn Audrey aropebur 1550

6. Write an insert statement in a text file named loademp.sql to load rows into the
MY_EMPLOYEE table. Concatenate the first letter of the first name and the first seven
characters
of the last name to produce the userid.

SET ECHO OFF


SET VERIFY OFF
INSERT INTO my_employee
VALUES (&p_id, ’&p_last_name’, ’&p_first_name’,
lower(substr(’&p_first_name’, 1, 1) ||
substr(’&p_last_name’, 1, 7)), &p_salary);
SET VERIFY ON
SET ECHO ON

7. Populate the table with the next two rows of sample data by running the insert statement in
the
script that you created.

SET ECHO OFF


SET VERIFY OFF
INSERT INTO my_employee
VALUES (&p_id, ’&p_last_name’, ’&p_first_name’,
lower(substr(’&p_first_name’, 1, 1) ||
substr(’&p_last_name’, 1, 7)), &p_salary);
SET VERIFY ON
SET ECHO ON
8. Confirm your additions to the table.

SELECT *
FROM my_employee;

9. Make the data additions permanent.

COMMIT;

Update and delete data in the MY_EMPLOYEE table.

10. Change the last name of employee 3 to Drexler.


UPDATE my_employee

SET last_name = ’Drexler’


WHERE id = 3;

11. Change the salary to 1000 for all employees with a salary less than 900.

UPDATE my_employee
SET salary = 1000
WHERE salary < 900;

12. Verify your changes to the table.

SELECT last_name, salary


FROM my_employee;

13. Delete Betty Dancs from the MY_EMPLOYEE table.

DELETE
FROM my_employee
WHERE last_name = ’Dancs’;

14. Confirm your changes to the table.

SELECT *
FROM my_employee;

15. Commit all pending changes.

COMMIT;
Control data transaction to the MY_EMPLOYEE table.
16. Populate the table with the last row of sample data by modifying the statements in the script
that
you created in step 6. Run the statements in the script.

SET ECHO OFF


SET VERIFY OFF
INSERT INTO my_employee
VALUES (&p_id, ’&p_last_name’, ’&p_first_name’,
lower(substr(’&p_first_name’, 1, 1) ||
substr(’&p_last_name’, 1, 7)), &p_salary);
SET VERIFY ON
SET ECHO ON

17. Confirm your addition to the table.

SELECT *
FROM my_employee;
18. Mark an intermediate point in the processing of the transaction.

SAVEPOINT step_18;

19. Empty the entire table.

DELETE
FROM my_employee;

20. Confirm that the table is empty.

SELECT *
FROM my_employee;

21. Discard the most recent DELETE operation without discarding the earlier INSERT operation.

ROLLBACK TO step_18;

22. Confirm that the new row is still intact.


SELECT *
FROM my_employee;

23. Make the data addition permanent.

COMMIT;

You might also like