[Oracle] transaction

Source: Internet
Author: User

Insert data using a subquery

Create Table emp2 (myid number (4), myname varchar2 (50), mydept number (5 ));

Insert into emp2 (myid, myname, mydept) Select empno, ename, deptno from EMP where deptno = 10;

Update Data Using subqueries (Oracle-specific)

We hope that Scott's position, salary, and subsidy will be consistent with Smith's:
Update EMP set (job, Sal, comm) = (select job, Sal, comm from EMP where ename = 'Smith ') Where ename = 'Scott ';

Transaction:
Transactions are used to ensure data consistency. They are composed of a group of related DML statements (data operation statements, add, delete, modify, and so on. The DML statements in this group are either all successful or all failed.

Lock:
When a transaction operation is performed, Oracle locks the affected table to prevent other users from changing the table structure.

Savepoint A1; create a save point
Statement
Rollback to Al; roll back, directly execute rollback to return the initial save point.

For example, after the commit command is executed, all save points are invalid. Automatically commit after exit.

How to Use transactions in Java:

Conn. setautocommit (false); // set not to submit by default
Add, delete, modify, and delete operations.
Conn. Commit ();
If an exception occurs, run conn. rollback ();

Read-only transactions
Only query operations are allowed. Other DML operations are not allowed.
Only obtain information at a specific time point.

SET transaction read only;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.