Xin Xin - 1 month ago 6
SQL Question

What is the view's isolation level when you set in store procedure level?

The title may be hard to read. scenario is like this:

I have a view: my_view (by default, it will be read committed)

Then I have just created a new SP, content is below:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
select *
from table1
inner join my_view


Now, of course, table1 will be read uncommitted, but what about my_view?
Is it read committed or read uncommitted?

Thanks

Answer

I have a view: my_view (read committed)

No, the view does not have an associated isolation level, as you seem to imply. The view is just a stored query. And that query will execute in whatever isolation level is in effect at the time you run it.

So if your view is queried from a stored procedure that sets the isolation level to read uncommitted (your example), then the query will be executed in that isolation level, simple as that.

Comments