Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Set a Transaction To Be READ ONLY
How To Set a Transaction To Be READ ONLY? - Oracle DBA FAQ - Understanding SQL Transaction Management
✍: FYIcenter.com
If you want a transaction to be set as READ ONLY, you need to the transaction with the SET TRANSACTION READ ONLY statement. Note that a DML statement will start the transaction automatically. So you have to issue the SET TRANSACTION statement before any DML statements. The tutorial exercise below shows you a good example of READ ONLY transaction:
SQL> connect HR/fyicenter SQL> SET TRANSACTION READ ONLY; Transaction set. SQL> SELECT * FROM fyi_links; ID URL NOTES COUNTS CREATED ------- ---------------- ---------- ---------- --------- 101 FYICENTER.COM 07-MAY-06 110 CENTERFYI.COM 07-MAY-06 112 oracle.com 07-MAY-06 113 sql.com 07-MAY-06
Keep the "HR" SQL*Plus window as is, and open another window to run another instance of SQL*Plus.
>cd (OracleXE home directory) >.\bin\sqlplus /nolog SQL> connect SYSTEM/password Connected. SQL> DELETE FROM hr.fyi_links where id = 112; 1 row deleted. SQL> DELETE FROM hr.fyi_links where id = 113; 1 row deleted. SQL> COMMIT; Commit complete.
Go back to the "HR" SQL*Plus window.
SQL> SELECT * FROM fyi_links; ID URL NOTES COUNTS CREATED ------- ---------------- ---------- ---------- --------- 101 FYICENTER.COM 07-MAY-06 110 CENTERFYI.COM 07-MAY-06 112 oracle.com 07-MAY-06 113 sql.com 07-MAY-06 SQL> COMMIT; Commit complete. SQL> SELECT * FROM fyi_links; ID URL NOTES COUNTS CREATED ------- ---------------- ---------- ---------- --------- 101 FYICENTER.COM 07-MAY-06 110 CENTERFYI.COM 07-MAY-06
As you can see that two records were deleted from another session after the HR session started the READ ONLY transaction. The deleted records was not impacting any query statements until the transaction was ended with the COMMIT statement.
2007-04-17, 4935👍, 0💬
Popular Posts:
In below sample code if we create a object of class2 which constructor will fire first? Public Class...
Can one change the mouse pointer in Forms? The SET_APPLICATION_PROPERTY build-in in Oracle Forms all...
What is triple constraint triangle in project management ? Project Management triangle is depicted a...
How To Define a Sub Function? - Oracle DBA FAQ - Creating Your Own PL/SQL Procedures and Functions A...
What is page thrashing? Some operating systems (such as UNIX or Windows in enhanced mode) use virtua...