|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Lock Tables
If the RDBMS is already ACID and SQL transaction has started,
WHAT SCENARIOS will cause us still to utilize LOCK tables to prevent from dirty data happening? What is the typical technique to lock tables of typical RDBMS like DB2 and Oracle? Please help. Thanks.
__________________
------------------------------------------ Perl Kids Kiss Perl Stanley ------------------------------------------ |
|
#2
|
|||
|
|||
|
Quote:
What exactly do you mean with "dirty data"? In Oracle for example you cannot prevent read access from a table by locking it. |
|
#3
|
||||
|
||||
|
Actually that was the question by an interviewer.
He was surprised that I did NOT LOCK tables by RDBMS specific commands (with SQL statements) for transactions of multiple user access. He said that if the tables were NOT LOCKed, multiple user access (insert, update, delete) will cause records wrong and inconsistent and contradicted or it is called as dirty data. I replied that any database supporting ACID and Transactions should prevent from dirty data. For example in ORACLE, Code:
SET AUTOCOMMIT OFF insert into RT values (1, 2); rollback; insert into RT values (3, 4); commit; or T-SQL: Code:
DECLARE @TranName VARCHAR(20) SELECT @TranName = 'MyTransaction' BEGIN TRANSACTION @TranName GO USE pubs GO UPDATE roysched SET royalty = royalty * 1.10 WHERE title_id LIKE 'Pc%' GO COMMIT TRANSACTION MyTransaction GO I don't know what scenario will cause explicitly LOCKing TABLE to become a MUST in ACID. If there is really such scenario, should we call program commands (e.g. JTS, JTA or else in JAVA) or DB specific commands (say Oracle, SQL Server, DB2)? ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Lock Tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|