Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
108 views3 pages

Module 6 - Exercise - Commit - TIONGSON

The document discusses transaction management in a database using SQL commands like INSERT, SELECT, DELETE, and COMMIT. It provides two examples: 1) A new person is inserted into the database table and SELECT is used to check if the insert is visible before and after COMMIT. 2) The inserted person is then deleted and SELECT is again used to check visibility before and after COMMIT. Explanations are provided that the changes are visible before COMMIT since the transaction is not yet complete, but will persist after COMMIT when the transaction is closed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views3 pages

Module 6 - Exercise - Commit - TIONGSON

The document discusses transaction management in a database using SQL commands like INSERT, SELECT, DELETE, and COMMIT. It provides two examples: 1) A new person is inserted into the database table and SELECT is used to check if the insert is visible before and after COMMIT. 2) The inserted person is then deleted and SELECT is again used to check visibility before and after COMMIT. Explanations are provided that the changes are visible before COMMIT since the transaction is not yet complete, but will persist after COMMIT when the transaction is closed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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