what lock is when inserting data
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


what lock is when inserting data Expand / Collapse
Author
Message
Posted 10/22/2009 2:34:09 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 10/23/2009 11:42:06 AM
Posts: 14, Visits: 43
Hi,
I want to know if I am inserting data from TBL1 to TBL2, what lock is on the TBL2.

I want to make sure when data is being inserted to TBL2 it is still available to read but not with half full data.

Ex -> 1. TBL2 is empty initially.

2. My query runs, which say takes about 2 hrs

insert into TBL2
select * from TBL1;

now in these 2 hrs if a user fires a query against the TBL2 he/she
should get: "0 rows returned".

Please help.
Thank you.
Shubh


shubhangi

Satyam
Post #17143
Posted 10/23/2009 8:27:58 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2 days ago @ 7:45:03 AM
Posts: 39, Visits: 169
You don't need to worry about locks in Teradata, TD automatically place appropriate mode of lock on tables or other database objects. In your case, it'll place WRITE lock on the table TBL2. Other users can read the table data through ACCESS mode lock, but not through READ lock.
Post #17147
Posted 10/23/2009 9:22:31 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: Yesterday @ 3:55:54 AM
Posts: 111, Visits: 263
Pawan is right - TBL2 gets a write lock.
If a user accesses the table, he will normally aquire a read lock, so will be delayed until the write lock is released. (This can be avoided by setting the NOWAIT option in bteq - other tools usually have equivalent options - in which case the command is rejected with table not available.)
If the user specifies LOCKING FOR ACCESS, he can read through the write lock, but will get the rows currently in the table, so could get any number of rows.
Post #17149
Posted 10/23/2009 11:42:55 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 10/23/2009 11:42:06 AM
Posts: 14, Visits: 43
Thanks a lot!! That was a great help..
I am all set for this..



shubhangi

Satyam
Post #17150
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 6:24pm

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.109. 9 queries. Compression Disabled.