J
jieking
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在遇到一个问题,有100万条数据表里,两个客户端同时insert和SELECT数据时死锁很严重,我的代码如下:
for i := 0 to aa - 1 do
begin
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SET TRANSACTION ISOLATION LEVEL READ COMMITTED ');
ADOQuery1.ExecSQL;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('insert into table(FD1,FD2,FD3,FD4)values(,1,1,1,4)');
ADOQuery1.ExecSQL;
end;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SET TRANSACTION ISOLATION LEVEL READ COMMITTED ');
ADOQuery1.ExecSQL;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from files WITH (Nolock) where FNo=''' + Edit1.Text + ''' ');
ADOQuery1.open
for i := 0 to aa - 1 do
begin
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SET TRANSACTION ISOLATION LEVEL READ COMMITTED ');
ADOQuery1.ExecSQL;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('insert into table(FD1,FD2,FD3,FD4)values(,1,1,1,4)');
ADOQuery1.ExecSQL;
end;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SET TRANSACTION ISOLATION LEVEL READ COMMITTED ');
ADOQuery1.ExecSQL;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('select * from files WITH (Nolock) where FNo=''' + Edit1.Text + ''' ');
ADOQuery1.open