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;