use XTS
--步骤一=============创建测试表===================================================
--测试表1
if(exists(select 1 from sysobjects where id=OBJECT_ID('testa')))
drop table testa
CREATE TABLE testa
(
id int primary key,--Id,并标记为主建
name varchar(10),--姓名
age decimal(26,4),--年龄
city varchar(10),--所在城市
address varchar(10),--家庭地址
remark text --备注
)
--创建非聚集索引
create unique nonclustered index testa_idx1 on testa(name,age)
--测试表2
if(exists(select 1 from sysobjects where id=OBJECT_ID('testb')))
drop table testb
CREATE TABLE testb
(
id int primary key,--Id,并标记为主建
name varchar(10),--姓名
age decimal(26,4),--年龄
city varchar(10),--所在城市
address varchar(10),--家庭地址
remark text --备注
)
--创建非聚集索引
create unique nonclustered index testb_idx1 on testb(name,age)
--步骤二===================添加测试数据================================================
insert into testa(id,name,age,city,address)
select 1,'joe',20,'hz','zjwz'
insert into testa(id,name,age,city,address)
select 2,'jill',25,'hz','zjhz'
insert into testa(id,name,age,city,address)
select 3,'Bob',27,'hz','zjhz'
insert into testb(id,name,age,city,address)
select 1,'joe',20,'hz','zjwz'
insert into testb(id,name,age,city,address)
select 2,'jill',25,'hz','zjhz'
insert into testb(id,name,age,city,address)
select 3,'Bob',27,'hz','zjhz'
--添加多一点,是为了查询效率降低,以便快速得到验证结果
declare @i int=4
while (@i<1000)
begin
insert into testa(id,name
SQL常见死锁例子及分析
最新推荐文章于 2024-08-08 09:33:58 发布
本文通过具体的SQL Server案例,深入剖析了死锁的发生原因和解决策略,帮助读者理解数据库操作中可能出现的死锁问题,并提供了解决此类问题的关键思路。
摘要由CSDN通过智能技术生成