Will Oracle lock the whole table while performing a DML statement or just the row

前端 未结 4 1825
南旧
南旧 2021-02-14 16:29

When i try to insert/update something in a db table, will Oracle lock the whole table or only the row being inserted/updated?

Is this something that can be controlled t

4条回答
  •  我在风中等你
    2021-02-14 16:59

    It depends what you mean by "lock".

    For 99.9% of what people are likely to care about, Oracle will acquire a row-level lock when a row is modified. The row-level lock still allows readers to read the row (because of multi-version read consistency, writers never block readers and readers never do dirty reads).

    If you poke around v$lock, you'll see that updating a row also takes out a lock on the table. But that lock only prevents another session from doing DDL on the table. Since you'd virtually never want to do DDL on an active table in the first place, that generally isn't something that would actually cause another session to wait for the lock.

提交回复
热议问题