Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Lock Table
DA Morgan <damorgan_at_psoug.org> wrote:
> xhoster_at_gmail.com wrote:
> > DA Morgan <damorgan_at_psoug.org> wrote:
> >>AnySQL (d.c.b.a) wrote:
> >>
> >>>you can change you sql to select (1) from my_table for update, else
> >>>oracle will never block reader.
> >>>
> >>It is impossible, in Oracle, to block a reader? Where are you getting
> >>your information?
> >
> >
> > "Select...for update" reads things. "Select...for update" blocks.
> > Hence, it is possible to block a reader.
> >
> > Xho
>
> Can you write a simple demo that demonstrates blocking a reader? I can
> see how to block an insert, update, or delete, but not a select.
Session 1:
SQL> create table foo ( bar varchar2(10));
Table created.
SQL> insert into foo values ('hi');
1 row created.
SQL> commit;
Commit complete.
SQL> update foo set bar='bye' where bar='hi';
1 row updated.
Session 2:
SQL> select * from foo where bar='hi' for update;
<At this point, the select has blocked>
Sesssion 1:
SQL> commit;
Commit complete.
Session 2: <immediately unblocks, giving:> no rows selected
Xho
-- -------------------- http://NewsReader.Com/ -------------------- Usenet Newsgroup Service $9.95/Month 30GBReceived on Thu Sep 08 2005 - 17:47:01 CDT