数据库:oracle 19.12
系统:rhel 8.4
实验目标:演练dcl语句的执行自动提交事务.
session1 执行.
SQL> select * from emp_copy;
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
----------- -------------------- --------------- --------------- -------------------- --------- ---------- ---------- -------------- ---------- -------------
100 Steven King SKING 515.123.4567 17-JUN-11 AD_PRES 24000 90
101 Neena Kochhar NKOCHHAR 515.123.4568 21-SEP-09 AD_VP 17000 100 90
102 Lex De Haan LDEHAAN 515.123.4569 13-JAN-09 AD_VP 17000 100 90
103 Alexander Hunold AHUNOLD 590.423.4567 03-JAN-14 IT_PROG 9000 102 80
104 Bruce Ernst BERNST 590.423.4568 21-MAY-15 IT_PROG 6000 103 80
107 Diana Lorentz DLORENTZ 590.423.5567 07-FEB-15 IT_PROG 4200 103 80
124 Kevin Mourgos KMOURGOS 650.123.5234 16-NOV-15 ST_MAN 5800 100 50
141 Trenna Rajs TRAJS 650.121.8009 17-OCT-11 ST_CLERK 3500 124 50
142 Curtis Davies CDAVIES 650.121.2994 29-JAN-13 ST_CLERK 3100 124 50
143 Randall Matos RMATOS 650.121.2874 15-MAR-14 ST_CLERK 2600 124 50
144 Peter Vargas PVARGAS 650.121.2004 09-JUL-14 ST_CLERK 2500 124 50
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
----------- -------------------- --------------- --------------- -------------------- --------- ---------- ---------- -------------- ---------- -------------
149 Eleni Zlotkey EZLOTKEY 011.44.1344.429018 29-JAN-16 SA_MAN 10500 .2 100 80
174 Ellen Abel EABEL 011.44.1644.429267 11-MAY-12 SA_REP 11000 .3 149 80
176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24-MAR-14 SA_REP 8600 .2 149 80
178 Kimberely Grant KGRANT 011.44.1644.429263 24-MAY-15 SA_REP 7000 .15 149
200 Jennifer Whalen JWHALEN 515.123.4444 17-SEP-11 AD_ASST 4400 101 10
201 Michael Hartstein MHARTSTE 515.123.5555 17-FEB-12 MK_MAN 13000 100 20
202 Pat Fay PFAY 603.123.6666 17-AUG-13 MK_REP 6000 201 20
205 Shelley Higgins SHIGGINS 515.123.8080 07-JUN-10 AC_MGR 12008 101 110
206 William Gietz WGIETZ 515.123.8181 07-JUN-10 AC_ACCOUNT 8300 205 110
20 rows selected.
SQL> delete from emp_copy;
20 rows deleted.
SQL> select * from emp_copy;
no rows selected
SQL> select sid from v$mystat where rownum=1;
SID
----------
391
现打开另一个session2,查看表emp_copy的数据.
SQL> select * from emp_copy
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
----------- -------------------- --------------- --------------- -------------------- --------- ---------- ---------- -------------- ---------- -------------
100 Steven King SKING 515.123.4567 17-JUN-11 AD_PRES 24000 90
101 Neena Kochhar NKOCHHAR 515.123.4568 21-SEP-09 AD_VP 17000 100 90
102 Lex De Haan LDEHAAN 515.123.4569 13-JAN-09 AD_VP 17000 100 90
103 Alexander Hunold AHUNOLD 590.423.4567 03-JAN-14 IT_PROG 9000 102 80
104 Bruce Ernst BERNST 590.423.4568 21-MAY-15 IT_PROG 6000 103 80
107 Diana Lorentz DLORENTZ 590.423.5567 07-FEB-15 IT_PROG 4200 103 80
124 Kevin Mourgos KMOURGOS 650.123.5234 16-NOV-15 ST_MAN 5800 100 50
141 Trenna Rajs TRAJS 650.121.8009 17-OCT-11 ST_CLERK 3500 124 50
142 Curtis Davies CDAVIES 650.121.2994 29-JAN-13 ST_CLERK 3100 124 50
143 Randall Matos RMATOS 650.121.2874 15-MAR-14 ST_CLERK 2600 124 50
144 Peter Vargas PVARGAS 650.121.2004 09-JUL-14 ST_CLERK 2500 124 50
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
----------- -------------------- --------------- --------------- -------------------- --------- ---------- ---------- -------------- ---------- -------------
149 Eleni Zlotkey EZLOTKEY 011.44.1344.429018 29-JAN-16 SA_MAN 10500 .2 100 80
174 Ellen Abel EABEL 011.44.1644.429267 11-MAY-12 SA_REP 11000 .3 149 80
176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24-MAR-14 SA_REP 8600 .2 149 80
178 Kimberely Grant KGRANT 011.44.1644.429263 24-MAY-15 SA_REP 7000 .15 149
200 Jennifer Whalen JWHALEN 515.123.4444 17-SEP-11 AD_ASST 4400 101 10
201 Michael Hartstein MHARTSTE 515.123.5555 17-FEB-12 MK_MAN 13000 100 20
202 Pat Fay PFAY 603.123.6666 17-AUG-13 MK_REP 6000 201 20
205 Shelley Higgins SHIGGINS 515.123.8080 07-JUN-10 AC_MGR 12008 101 110
206 William Gietz WGIETZ 515.123.8181 07-JUN-10 AC_ACCOUNT 8300 205 110
20 rows selected.
SQL> select sid from v$mystat where rownum=1;
SID
----------
32
session2中表emp_copy中数据是存在的.
现在session1中执行一个dcl语句:
SQL> grant select on employees to hr;
Grant succeeded.
session2再次查看.
SQL> select sid from v$mystat where rownum=1;
SID
----------
32
SQL> select * from emp_copy;
no rows selected
说明:session2已查询不到表信息,session1执行的grant语句自动提交了delete操作.