Oracle operating statement - add / remove

1. Delete employee information 1980 employees;

delete  from myemp

where     hiredate between to_date('1980-1-1','yyyy-mm-dd')

      and to_date('1980-12-31','yyyy-mm-dd') ;

After executing the above statement actually has not been updated in the true sense, you must perform the following statement will be completely removed, or when the other session query session, in 1980, employee information still exists. But when you exit Oracle will automatically commit the.

      COMMIT WORK;

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2, transactional operations command

S . 1: SCOTT users are logged two the SQL PLUS and windows are session1 Session2; 

 

 

S2: session1 and session2 window view, respectively myemp information data table;

 

S3: window session1, execute the statement:

INSERT

INTO myemp(empno,ename,hiredate, job, sal)

VALUES (1234, ' Li Xinghua ', to_date ( '1989-09-19', 'yyyy-mm-dd'), 'MANAGER', 3000);

 

UPDATE MYEMP

SET SAL=5000 WHERE EMPNO=1234;

 

SAVEPOINT SP_A;

 

SELECT count(*) FROM myemp;

result:

 

 

Switch windows session2, execute the statement:

SELECT count(*) FROM myemp;

result:

 

 

 

S4: window session1, execute the statement:

INSERT

 INTO myemp(empno,ename,hiredate, job, sal)

 VALUES(5678,'董鸣楠',to_date('2003-07-27','yyyy-mm-dd'), 'HR',2000);

 

UPDATE myemp

SET job='CEO' WHERE empno=5678;

 

SAVEPOINT SP_B;

 

SELECT count(*) FROM myemp;

result:

 

 

Switch windows session2, execute the statement:

SELECT count(*) FROM myemp;

result:

 

 

S5: window session1, execute the statement:

DELETE FROM myemp;

SELECT count(*) FROM myemp;

result:

 

 

Switch windows session2, execute the statement:

SELECT count(*) FROM myemp;

result:

 

S6: window session1, execute the statement:

S6: window session1, execute the statement:

- to use the rollback node sp_B
ROLLBACK the TO SP_B;
the SELECT COUNT (*) the FROM myemp;

 

 

ROLLBACK TO SP_A;

SELECT count(*) FROM myemp;

 

 

ROLLBACK;

SELECT count(*) FROM myemp

 

 

S7: window session1, execute the statement:

INSERT

 INTO myemp(empno,ename,hiredate, job, sal)

 VALUES(5678,'董鸣楠',to_date('2003-07-27','yyyy-mm-dd'), 'HR',2000);

 

UPDATE myemp

SET job='CEO' WHERE empno=5678;

 

COMMIT;

 

SELECT count(*) FROM myemp;

result:

 

 

 

Switch windows session2, execute the statement:

SELECT count(*) FROM myemp;

result:

 

--- The main purpose of the above experiment is to make the reader understand the settings saved node, and the usage of the rollback event, there is the use delete statements and insert statements must commit statement, or just view displays the results you want it, other session session invisible operation, although after he quit Oracle will automatically commit, but safe still commit, another session at the same time before they can log in to see the update operation.

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/hmy-666/p/11824982.html