|
|
|
|
|
Stats |
Total Topics
Total Topic Views
Total Comments
Unique Visitors
Total Visitors |
: 45
: 683253
: 44
|
|
|
|
|
|
About this blog…About this blog…
About MeAbout Me
Favourite LinksFavourite Links
Neden hazır blog'ları kullanmadım ki?Neden hazır blog'ları kullanmadım ki?
CSS is more powerful than you imagineCSS is more powerful than you imagine
Turkcell Staj Günlüğü - 1: Introduction to OracleTurkcell Staj Günlüğü - 1: Introduction to Oracle
Turkcell Staj Günlüğü - 2: Data Blocks, Extends and SegmentsTurkcell Staj Günlüğü - 2: Data Blocks, Extends and Segments
Kahin'e yolculuk nasıl başlamalı?Kahin'e yolculuk nasıl başlamalı?
Turkcell Staj Günlüğü - 3: Tablespaces, Datafiles and Control FilesTurkcell Staj Günlüğü - 3: Tablespaces, Datafiles and Control Files
Turkcell Staj Günlüğü - 4: Transaction ManagementTurkcell Staj Günlüğü - 4: Transaction Management
Image formats - Which to use whenImage formats - Which to use when
Turkcell Staj Günlüğü - 5: Startup, ShutdownTurkcell Staj Günlüğü - 5: Startup, Shutdown
Turkcell Staj Günlüğü - 6: Oracle ArchitectureTurkcell Staj Günlüğü - 6: Oracle Architecture
ASP - Locales and CodepagesASP - Locales and Codepages
Oracle performance analysis - Tracing and performance evaluationOracle performance analysis - Tracing and performance evaluation
Oracle performance analysis - Autotrace workshopOracle performance analysis - Autotrace workshop
Oracle performance analysis - Runstats workshopOracle performance analysis - Runstats workshop
Oracle performance analysis - Tkprof workshopOracle performance analysis - Tkprof workshop
Some favourite quotesSome favourite quotes
Derin anlamlı sözler - Bunlar da Türkçe olanlar :)Derin anlamlı sözler - Bunlar da Türkçe olanlar :)
Turkcell Staj Günlüğü - 7: Concurrency and ConsistencyTurkcell Staj Günlüğü - 7: Concurrency and Consistency
"Kurtuluş"un hikayesi"Kurtuluş"un hikayesi
Turkcell Staj Günlüğü - 8: Statement Processing and CBOTurkcell Staj Günlüğü - 8: Statement Processing and CBO
When a transaction begins?When a transaction begins?
Implicit vs. Explicit cursors - Performance analysisImplicit vs. Explicit cursors - Performance analysis
Turkcell Staj Günlüğü - 9: "SQL, PL/SQL and Java" ve "Redo Internals"Turkcell Staj Günlüğü - 9: "SQL, PL/SQL and Java" ve "Redo Internals"
Affect of gathering table stats to decision of CBOAffect of gathering table stats to decision of CBO
Bind is bad :) - An interesting case of bind variables failsBind is bad :) - An interesting case of bind variables fails
When the explanation doesn't sound quite right...When the explanation doesn't sound quite right...
Turkcell Staj Günlüğü - 10: Import, Export ve SQL LoaderTurkcell Staj Günlüğü - 10: Import, Export ve SQL Loader
Turkcell Staj Günlüğü - 11: Autonomous Transactions ve Dynamic SQLTurkcell Staj Günlüğü - 11: Autonomous Transactions ve Dynamic SQL
Difference between db block gets and consistent getsDifference between db block gets and consistent gets
Object-Oriented Features of Oracle - Part 1: Native Datatypes vs. Object DatatypesObject-Oriented Features of Oracle - Part 1: Native Datatypes vs. Object Datatypes
Object-Oriented Features of Oracle - Part 2: Object Types and Collection typesObject-Oriented Features of Oracle - Part 2: Object Types and Collection types
Object-Oriented Features of Oracle - Part 3: Object Tables, Object Views and REFsObject-Oriented Features of Oracle - Part 3: Object Tables, Object Views and REFs
Examining show_spaceExamining show_space
Turkcell Staj Günlüğü - 12: PartitioningTurkcell Staj Günlüğü - 12: Partitioning
Hello World!Hello World!
Decode Demo #1Decode Demo #1
Decode Demo #2Decode Demo #2
Decode Demo #3Decode Demo #3
Decode Demo #4Decode Demo #4
Decode Function in Oracle SQLDecode Function in Oracle SQL
Windows Source CodesWindows Source Codes
Türkçe Karakterli Domain'lerin İç YüzüTürkçe Karakterli Domain'lerin İç Yüzü
Whence C? Why C? Whither C?Whence C? Why C? Whither C?
Differences between C and C++Differences between C and C++
Is C a Vitamin? Yes, of course...Is C a Vitamin? Yes, of course...
Obfuscated CObfuscated C
Finding and Removing Loop on a Singly-Linked ListFinding and Removing Loop on a Singly-Linked List
Matematik Asla Yalan Söylemez!Matematik Asla Yalan Söylemez!
|
|
|
|
|
|
When a transaction begins?
|
Category: SQL-Oracle-PL/SQL
Date: 24.07.2007 19:02:39
|
A transaction is a logical unit of work that contains one or more SQL statements. A transaction is an atomic unit. The effects of all the SQL statements in a transaction can be either all committed (applied to the database) or all rolled back (undone from the database).
Transaction management is the main mechanism that distinguishes between DBMS from other DBMS and DBMS from file system. The main purpose is to take the database from one consistent state to next. This satisfies the consistency of database for many cuncurrent users. That is imposible with file systems.
In Oracle, every manipulation statement must be in a transaction, so whether you give a "set transaction" command or not, Oracle opens a transaction. It is obvious that a transaction ends with a commit or rollback command. But it actually is not obvious that when a transaction begins.
Many peope say that "A transaction begins with first DML statement" or like that. I will show you some examples and some experimental about that. But first, we will look at some descriptions about that.
In Oracle 10gR2 Documentation, it is written like "A transaction begins with the first executable SQL statement". That is ambiguous, what is an "executable statement". In what conditions a transaction begins.
Also some people writes like "A new transaction begins when a session is opened and after each rollback or commit". That is really wrong, no doubt about it :)
And I see some descriptions about this topic like "Transaction begins at execution of first data change" or like "A transaction begins with the first statement that gets a TX lock" (that is first statement that modifies data). These are actually true. I will illustrate with examples now. There are a lot of things to understand for knowing people. I will not comment for each of them.
SQL> conn test@bilalEE as sysdba
Connected.
SQL> select * from v$transaction;
no rows selected
SQL> create table t as select rownum n from all_objects where rownum < 1000;
Table created.
SQL> select * from v$transaction;
no rows selected
SQL> select * from t where n=1;
N
----------
1
SQL> select * from v$transaction;
no rows selected
SQL> update t set n=2000 where n=3000;
0 rows updated.
SQL> select * from v$transaction;
no rows selected
SQL> delete from t where n=3000;
0 rows deleted.
SQL> select * from v$transaction;
no rows selected
SQL> alter table t add constraint pk_t primary key(n);
Table altered.
SQL> select * from v$transaction;
no rows selected
SQL> insert into t values(500);
insert into t values(500)
*
ERROR at line 1:
ORA-00001: unique constraint (SYS.PK_T) violated
SQL> select * from v$transaction;
no rows selected
SQL> create trigger trig_t before insert on t
2 begin
3 raise_application_error(-20001,'trigger not allows to insert to this table');
4 end;
5 /
Trigger created.
SQL> select * from v$transaction;
no rows selected
SQL> insert into t values(1001);
insert into t values(1001)
*
ERROR at line 1:
ORA-20001: trigger not allows to insert to this table
ORA-06512: at "TEST.TRIG_T", line 2
ORA-04088: error during execution of trigger 'TEST.TRIG_T'
SQL> select * from v$transaction;
no rows selected
SQL> savepoint sp1;
Savepoint created.
SQL> select * from v$transaction;
no rows selected
SQL> create procedure test_p as
2 begin
3 dbms_output.put_line('selam');
4 end;
5 /
Procedure created.
SQL> select * from v$transaction;
no rows selected
SQL> exec test_p;
selam
PL/SQL procedure successfully completed.
SQL> select * from v$transaction;
no rows selected
SQL> update t set n=1000 where n=999;
1 row updated.
SQL> select * from v$transaction;
ADDR XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC ST
-------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --
288E7124 8 44 305 2 1309 203 58 AC
SQL>
Download Code
|
|
Related Topics |
|
|
|
Links & References |
|
|
|
|
|
|
|
|
|
|
|
|
by the way SELECT ideed a DML - for update example
|
Name: TongucY
URL: http://tonguc.yilmaz.googlepages.com
Date: 24.08.2007 19:26:12
|
[oracle@tcellhost ~]$ sqlplus hr/hr
SQL*Plus: Release 10.2.0.3.0 - Production on Fri Aug 24 19:18:50 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production With the Partitioning, OLAP and Data Mining options
SQL>
drop table tt purge ; create table tt nologging as select rownum n from all_objects where rownum < 1000; select count(*) from v$transaction;
select * from tt where n=1 for update ; select count(*) from v$transaction;
COUNT(*) ---------- 0
N ---------- 1
COUNT(*) ---------- 1
|
|
|
|
|
|