You are on page 1of 3

ITTOOLS – Module 6 – Transaction Management

Submitted by Abby Gail A. Tiongson AC181

Exercise – Commit
Read the problem carefully and write the answer on the spaces
provided for below.

#1:
Let us insert a new person into the database and test the COMMIT.

-- Store a new person with id 99.

INSERT INTO person (id, firstname, lastname, date_of_birth, place_of_birth, ssn, weight)
VALUES(99, 'Harriet', 'Flint', DATE'1970-10-19', 'Dallas', '078-05-1120', 65);

Question 1_1:
-- Is the new person really in the database? The process which executes the write
-- operation will see its results, even if they are actually not committed. (One hit
expected.)

SELECT *
FROM person
WHERE id = 99;

-- Try COMMIT command


COMMIT;

Question 1_2:
-- After committing, Is she still in the database? (One hit expected.)

SELECT *
FROM person
WHERE id = 99;
-------------------------------------------------------------------------------------------------------------
Yes or No? Then explain why.
Answer 1_1: Yes, the new person or the record is really in the database because
even if the transaction was not yet closed or completed by a commit command,
the insert command already inputs the data in the database. Although, if we
accidentally close the DBMS, the data might “rollback” as it is not yet persistent.
ITTOOLS – Module 6 – Transaction Management
Submitted by Abby Gail A. Tiongson AC181

Answer 1_2: Yes, the record is still in the database after committing because the
transaction is finally closed or completed. Hence, even if we use a “rollback”
command the record in the database or if we close the DBMS accidentally, the
record will not be deleted as the transaction is already persistent.

#2.

Now we remove the person from the database.

-- Remove the new person


DELETE
FROM person
WHERE id = 99;

Question 2_1.

-- Is the person with id=99 really gone? Again, the process which performs the
delete operation -- will see the changes, even if they are actually not committed.

SELECT *
FROM person
WHERE id = 99;

-- Try COMMIT command


COMMIT;

Question 2_1.

-- After committing, Is that person really gone in the database?

SELECT *
FROM person
WHERE id = 99;

-------------------------------------------------------------------------------------------------------------
Yes or No? Then explain why.
ITTOOLS – Module 6 – Transaction Management
Submitted by Abby Gail A. Tiongson AC181
Answer 2_1: Yes, the person with id=99 is really gone or deleted in the database
because even if the transaction is not completed by a ‘commit’ command, the
record is removed by a “delete” command. Although, there’s a chance that it
might still exist once you reopen the DBMS as the transaction is not yet saved by a
commit command, hence, not yet persistent.

Answer 2_2: Yes, the person with id=99 is really gone or deleted in the database
because the transaction is completed by a ‘commit’ command. Hence, the record
is permanently deleted or removed in the database. This means that you will not
be able to retrieve this record again, so you’ll need to create a new transaction if
you choose to bring it back.

You might also like