12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Transaction Control StatementsThis topic includes the following topics:■■Committing Transaction ChangesRolling Back a Transaction6.4.1 Committing Transaction ChangesThe <strong>SQL</strong> COMMIT statement saves any changes you have made to the database. Whena COMMIT has been executed, all the recent changes since the last COMMIT, or since youlogged on as the current user, are saved.Example 6–11 shows how to use COMMIT to commit (save) changes to the employeestable in the database.Example 6–11 Using the COMMIT Statement-- add a row and then update the dataINSERT INTO employees (employee_id, last_name, email, hire_date, job_id, salary)VALUES (301, 'Doe', 'john.doe', '31-AUG-05', 'SH_CLERK', 2400);UPDATE employees SET salary = salary*1.10 WHERE employee_id = 301;-- commit (save) the INSERT and UPDATE changes in the databaseCOMMIT;See Also:■<strong>Oracle</strong> Database <strong>SQL</strong> Reference for information on the COMMITstatement.6.4.2 Rolling Back a TransactionYou can use the <strong>SQL</strong> ROLLBACK statement to rollback (undo) any changes you made tothe database before a COMMIT has been executed.Example 6–12 shows how to use ROLLBACK to rollback the deletions made to theemployees table. Note that the ROLLBACK was issued before a COMMIT was executed.Example 6–12Using the ROLLBACK Statement-- delete a row (record)DELETE FROM employees WHERE last_name = 'Doe';-- rollback the delete statement because the previous DELETE was incorrectROLLBACK;-- the following is validSELECT * FROM employees WHERE last_name = 'Doe';See Also:■<strong>Oracle</strong> Database <strong>SQL</strong> Reference for information on the ROLLBACKstatement.<strong>SQL</strong>: Usage Information 6-9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!