I have a SQL table that will be accessed by two console apps (.NET). One will be inserting and other one will be reading/updating.
If two apps run at the same time, would there be any probl开发者_高级运维ems? I am guessing that the table will be locked until one app closes the connection.
But, is there a way both can use the table at the same time?
Thanks.
T SQL
Refer Transaction Isolation levels to see what options and kinds of locking you have, and which one makes more sense.
C#
Refer Transaction class which will let you similar isolation levels to make your apps work as you want.
Generally when there is more than one reader/writers to any data source it might so happen that reader might read half of the data which is currently being written by writer. Therefore based on the way you want your applications to behave you'd use the isolation levels to control how locking should work.
Read Uncommitted - High performance, but you might sometime see half written (incomplete writes) in your reads.
Repeatable Read - Tables are locked for reading, you could repeatedly fetch same data in a transaction.
Read Committed - No half written data is read, always read waits for write to complete.
I'm not completely sure if I've given correct meanings here, this is what I remember, and I'd never trust my memory when I can go back and refer to these documentation.
There shouldn't be problems.. SQL Server is built to handle multiple users modifying the same data.
精彩评论