Preview

Concurrency control

Powerful Essays
Open Document
Open Document
1856 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Concurrency control
Transactions

1. In this exercise, you will see how to rollback or commit transactions. By default PostgreSQL commits each SQL statement as soon as it is submitted. To prevent the transaction from committing immediately, you have to issue a command begin; to tell PostgreSQL to not commit immediately. You can issue any number of SQL statements after this, and then either commit; to commit the transaction, or rollback; to rollback the transaction. To see the effect, execute the following commands one at a time begin ; select * from student where name = 'Tanaka';
ID Name Dept_name Tot_Cred
--------------------------------------------------
98988 Tanaka Biology 120

delete from student where name = 'Tanaka';
Query returned successfully: one row affected, 234 ms execution time.

select * from student where name = 'Tanaka';
Total query runtime: 15 ms.
0 rows retrieved.

rollback;
NOTICE: there is no transaction in progress
Query returned successfully with no result in 16 ms.

select * from student where name = 'Tanaka';
ID Name Dept_name Tot_Cred
----------------------------------------------------------------------------
98988 Tanaka Biology 120

In the above example it explains the importance of begin and rollback used together; I have shown output after performing every command. And later have explained the observation.

Observation: In the above example we are having begin command to be executed in the first line which will indicates that until we commit the update transaction the DB system won’t save the updating in the tables. In the next line we select the details of student named ‘Tanaka’ since there is no updating it will show the record ‘Tanaka’ from the student table. The next command we perform is the delete command which removes the record of student named ‘Tanaka’ from the student table so that, the student table will be updated. In the next line we again search for the student named ‘Tanaka’ from

You May Also Find These Documents Helpful

  • Satisfactory Essays

    - Any action that a database takes, creating objects, adding rows, changing data in rows, removing rows, and so on.…

    • 327 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    the first one? Because it only backed up the changes I made since the last backup. Incremental…

    • 776 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Unit 6 True

    • 287 Words
    • 1 Page

    The WHERE clause is used to set criteria by which to filter which rows are returned or affected. TRUE…

    • 287 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    Pride Case Study

    • 486 Words
    • 2 Pages

    References: Person(PersonID) On Delete No Action” ensures that every row from Workout table will correspond to some row in the Person table.…

    • 486 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    07

    • 4772 Words
    • 25 Pages

    11) The SQL keyword MODIFY is used to change the structure, properties or constraints of a table.…

    • 4772 Words
    • 25 Pages
    Good Essays
  • Satisfactory Essays

    3. In the forward() command, what does the number argument inside the parentheses do? (1.0 points)…

    • 290 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    04

    • 4586 Words
    • 34 Pages

    The MODIFY clause is used with the ALTER TABLE command to add a PRIMARY KEY constraint to an existing table.…

    • 4586 Words
    • 34 Pages
    Satisfactory Essays
  • Powerful Essays

    I declare that this assignment is our own work. I further declare that where material has been used from other sources, whether by paraphrasing or by direct quotation, it has been fully acknowledged and referenced. I have retained a copy of this assignment for my records.…

    • 5443 Words
    • 22 Pages
    Powerful Essays
  • Good Essays

    homework

    • 548 Words
    • 16 Pages

    Drawing on material covered in prior chapters, explain the factors to be considered in deciding whether to create a key index for a table in SQL. (Hint: there are three.)…

    • 548 Words
    • 16 Pages
    Good Essays
  • Satisfactory Essays

    CNE 251 Lab 07

    • 548 Words
    • 2 Pages

    8) There is not stdout message or error message as a result of this. Nothing was changed from the previous data.…

    • 548 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    -Communication is the activity of conveying information. Communication requires a sender, a message, and an intended recipient, although the receiver need not be present or aware of the sender's intent to communicate at the time of communication; thus communication can occur across vast…

    • 1724 Words
    • 7 Pages
    Powerful Essays
  • Satisfactory Essays

    Hibernate

    • 309 Words
    • 2 Pages

    Small change in the java code will alter the table in the DB. Needn’t dropping the table.…

    • 309 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    database triggers

    • 1673 Words
    • 7 Pages

    ON orders DECLARE vMsg VARCHAR2(30) : = 'Statement Level Trigger Fired'; BEGIN IF INSERTING THEN dbms_output.put_line(vMsg || ' When Inserting'); ELSIF UPDATING THEN dbms_output.put_line(vMsg || ' When Updating'); ELSIF DELETING THEN dbms_output.put_line(vMsg || ' When Deleting'); END IF; END statement_level; / set serveroutput on INSERT INTO orders (somecolumn) VALUES ('ABC'); UPDATE orders SET somecolumn = 'DEF' WHERE ROWNUM = 1; DELETE FROM orders WHERE ROWNUM = 1; Create Row Level…

    • 1673 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    Chumma

    • 311 Words
    • 2 Pages

    LAB 4 STUDENT NAME: Rajendhar Dayalan Student ID:12667690 Q1 Please write down the modified script for creating the add_jobs procedure into your report. CREATE OR REPLACE PROCEDURE ADD_JOBS (p_jobid IN jobs.job_id%TYPE, p_jobtitle IN jobs.job_title%TYPE, p_minsal IN jobs.min_salary%TYPE ) is v_maxsal jobs.max_salary%TYPE; BEGIN v_maxsal:= 2* p_minsal; Insert into jobs values(p_jobid,p_jobtitle,p_minsal,v_maxsal); DBMS_OUTPUT.PUT_LINE ('Added the following row into the JOBS table ...'); DBMS_OUTPUT.PUT_LINE (p_jobid || ' ' || p_jobtitle || ' '|| p_minsal || ' ' || v_maxsal); END ADD_JOBS; Q2 Please write down the modified script for creating the get_service_days function into your report. (2 pts) CREATE OR REPLACE FUNCTION GET_SERVICE_DAYS (p_empid IN employees.employee_id%TYPE)…

    • 311 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Tute 7

    • 507 Words
    • 2 Pages

    3. Consistency: Consistency is the key when entering information into a database. If a field is set to…

    • 507 Words
    • 2 Pages
    Satisfactory Essays