I am developing an application which fetches some data from a Teradata DWH. DWH developers told me to use LOCK ROW FOR ACCESS
before all SELECT
queries to avoid delaying writes to that table(s).
Being very familiar with MS SQL Servers's WITH(NOLOCK)
hint, I see LOCK ROW FOR ACCESS
as its equivalent. However, INSERT
or UPDATE
statements do not allow using LOCK ROW FOR ACCESS
(it is not clear for me why this fails, since it should apply for table(s) the statement selects from, not to the one I insert into):
-- this works
LOCK ROW FOR ACCESS
SELECT Cols
FROM Table
-- this does not work
LOCK ROW FOR ACCESS
INSERT INTO SomeVolatile
SELECT Cols
FROM PersistentTable
I have seen that LOCKING TABLE ... FOR ACCESS
can be used, but it is unclear if it fits my need (NOLOCK
equivalent - do not block writes).
Question: What hint should I use to minimize writes delaying when selecting within an INSERT
statement?