Sie sind auf Seite 1von 5

NAME: MICHAEL JORDAN A.

PASCUAL COURSE: BSCS


TITLE: Applying Database Transaction USN ID: 20160008916
MACHINE ACTIVITY NO. 2 DATE: 12-05-2019

Direction: Follow the steps accordingly.


1. Download the DEPARTMENTS table.
2. Copy and paste the pl/sql code used during the creation of DEPARTMENTS
table.
3. After copying all the values inside the DEPARTMENTS table type in COMMIT
followed by semicolon to end your statement.
Note: Succeeding numbers requires you to use Departments table. Perform the
following transaction as instructed in each number. Skipping one step may cause
incorrect answer. If there is/are question(s) that you have to explain based on the output
write your answer (in Red Color Font) for each question.

Table 1.0
Current State of Departments table.

1. Update the DEPARTMENT_NAME to PROMODIZER of all departments where


LOCATION_ID is equal to 1700.
UPDATE DEPARTMENTS
SET DEPARTMENT_NAME='PROMODIZER'
WHERE LOCATION_ID=1700;

2. After updating records in No. 1, create a savepoint rename your savepoint as


UPDATE_PROMO.
SAVEPOINT UPDATE_PROMO;

3. Delete the record of MANAGER_ID that is/are equal to NULL or blank.


DELETE FROM DEPARTMENTS
WHERE MANAGER_ID IS NULL;

CS352-DBMS2-MAS Page 1
NAME: MICHAEL JORDAN A. PASCUAL COURSE: BSCS
TITLE: Applying Database Transaction USN ID: 20160008916
MACHINE ACTIVITY NO. 2 DATE: 12-05-2019

4. After updating records in No. 3, create a savepoint rename your savepoint as


DELETE_NULL;
SAVEPOINT DELETE_NULL;

5. Check the changes made in DEPARTMENTS table and study by issuing


SELECT * command.
6. After checking the changes made from No. 1 - 4. Add additional department as
shown below
DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
70 CLERK 100 1200
40 IT 100 1300
INSERT INTO DEPARTMENTS VALUES (70,'CLERK',100,1200);
INSERT INTO DEPARTMENTS VALUES (40,'IT',100,1300);

7. After inserting values in No. 6. Check the changes made to the table by issuing
the SELECT * command.
8. Rolled back to the savepoint you have created in No. 3.
ROLLBACK TO DELETE_NULL;

9. After Rolling back to the savepoint created in No. 3 check the departments table
by issuing SELECT * command.
10. After checking the changes made. What Happen to the delete statement made at
No. 3 as well as the Insert statement made at No. 6. Why is that so?
The delete statement was not rollback because the savepoint executed is
after deleting the MANAGER_ID IS NULL and the VALUES ADDED in No. 6
was also rollback to the savepoint DELETE_NULL the savepoint is before
the No. 6 item.

11. Create a new table name as Parts with the following structure as shown below.

12. Add additional values to PARTS table as shown below:


PART_NUM DESCRIPTION ONHAND PRICE
AT95 OVEN 10 1402
INSERT INTO PARTS

CS352-DBMS2-MAS Page 2
NAME: MICHAEL JORDAN A. PASCUAL COURSE: BSCS
TITLE: Applying Database Transaction USN ID: 20160008916
MACHINE ACTIVITY NO. 2 DATE: 12-05-2019

VALUES(‘AT95’,’OVEN’,10,1402);
13. View the records both for Departments and Parts table by issuing SELECT *
command?
14. Discard all the changes performed by issuing ROLLBACK statement.
ROLLBACK;

15. What happens to the Departments table? Is creating a new Table Parts affect the
departments table? Why and why not.
What happens to the Parts table is adding values successful? Why and why not.
DEPARTMENTS TABLE IS STILL IN THE COMMAND LINE BECAUSE
AUTOMATIC COMMIT EXECUTED ONCE YOU CREATED A NEW TABLE.

CREATING NEW TABLE DOES NOT AFFECTED THE DEPARTMENTS


TABLE BECAUSE OF AUTOMATIC COMMIT TRANSACTION AFTER
CREATING NEW TABLE.

TABLE PARTS VALUES IS SUCCESSFULLY ADDED IN THE COMMAND


LINE BUT AFTER THE ROLLBACK STATEMENT IS EXECUTED ITS
AUTOMATICALLY DELETED THE VALUES ADDED IN THE TABLE PARTS
AND BACK INTO THE LAST COMMIT TRANSACTION.

16. Add additional values to PARTS table as shown below:


PART_NUM DESCRIPTION ONHAND PRICE
MO35 Microwave 4 5643
WS01 Washing 1 5732
INSERT INTO PARTS VALUES (‘M035’,’MICROWAVE’,4,5643);
INSERT INTO PARTS VALUES (‘WS01’,’WASHING’,1,5732);

17. After new record to Parts table. Exit the SQLPLUS (by clicking ex button located
at the upper right corner). After closing open again the SQLPLUS and view both
Departments and Parts table by issuing SELECT * statement.
18. What happen to the Parts table? Is abnormal exit of oracle causes any problem?
Is the insertion maid at No. 16 is saved? Explain in detail why and why not. What
happens to the Parts table is adding values successful? Why and why not.
PARTS TABLE VALUES IS DELETED BECAUSE OF AUTOMATICALLY
ROLLBACK BACK CLOSING THE COMMAND LINE USING THE X BUTTON.

ABNORMAL EXIT OR SYSTEM FAILURE IS AUTOMATICALLY ROLLBACK


THE TRANSACTION TO ITS PREVIOUS STATE.

CS352-DBMS2-MAS Page 3
NAME: MICHAEL JORDAN A. PASCUAL COURSE: BSCS
TITLE: Applying Database Transaction USN ID: 20160008916
MACHINE ACTIVITY NO. 2 DATE: 12-05-2019

INSERTION OF VALUES IN PARTS TABLE IS SUCCESFULLY ADDED BUT


IN CLOSING THE COMMAND LINE USING THE X BUTTON THE VALUES
ADDED IS AUTOMATICALLY ROLLBACK THE PARTS TABLE HAS NO
ROWS SELECTED IF YOU EXECUTE SELECT * FROM PARTS;

19. Truncate the Departments table by issuing TRUNCATE DEPARTMENTS.


TRUNCATE TABLE DEPARTMENTS;

20. Then Rollback the changes made by issuing ROLLBACK statement.


ROLLBACK;

21. Check the departments table by issuing SELECT * command? What happens to
departments table? Are there still values in it? Why and Why not?
THE VALUES IN DEPARTMENTS TABLE IS DELETED BECAUSE OF USING
TRUNCATE STATEMENT.

USING OF TRUNCATE STATEMENT REMOVES ALL ROWS FROM A TABLE


BUT THE STRUCTURE AND ITS COLUMN AND SO ON IS REMAIN.
EXECUTING TRUNCATE STATEMENT CAN’T USE THE ROLLBACK
ANYMORE.

22. Truncate and Drop Statement are said to the limitation of Database Transaction.
Explain the reason why.
TRUNCATE AND DROP CANNOT BE ROLLED BACK.

TRUNCATE STATEMENT REMOVES ALL ROWS FROM A TABLE


BUT THE STRUCTURE AND ITS COLUMN AND SO ON IS REMAIN.
EXECUTING TRUNCATE STATEMENT CAN’T USE THE ROLLBACK
ANYMORE.

DROP STATEMENT REMOVES A TABLE FROM DATABASE AND ALL THE


TABLES ROWS, INDEXES AND PRIVILEGES WILL ALSO REMOVED.

23. Count the number of transactions performed. How many transaction made?
4 TRANSACTIONS
24. What is the difference in using ROLLBACK TO SAVEPOINT to ROLLBACK?
ROLLBACK TO SAVEPOINT TRANSACTION IS USED IF YOU WANT TO
ROLLBACK YOUR DATABASE INFORMATION INTO THE SAVEPOINT
NAME YOU CREATED.

CS352-DBMS2-MAS Page 4
NAME: MICHAEL JORDAN A. PASCUAL COURSE: BSCS
TITLE: Applying Database Transaction USN ID: 20160008916
MACHINE ACTIVITY NO. 2 DATE: 12-05-2019

AND THE ROLLBACK TRANSACTION IS USED TO ROLLBACK THE


TRANSACTIONS OR STATEMENT YOU MADE IN DATABASE TO ITS LAST
CONFIGURATION OR THE LAST STATEMENT YOU EXECUTED.

25. Provide a screen capture of the current state of both Departments and Parts
table by issuing SELECT * statement.
(Add the current state of your 2 tables here)
DEPARTMENTS TABLE

PARTS TABLE

CS352-DBMS2-MAS Page 5

Das könnte Ihnen auch gefallen