sql server新增列阻塞案例

2022-09-20 10:33:13 字數 1589 閱讀 7715

if

db_id('

test

') is

null

create

database

test;

gouse

test;

ifdb_id('

test1

') is

notnull

begin

drop

table

test1

end;

withtas

(

select

1as id,'

abcdef'as

str1

union

allselect id+

1,str1 from

t

where id+

1<=

1000000

)select

*into test1 from t option(maxrecursion 0

) ;create

clustered

index cix_id on

test1(id)

go

(1.2)測試會話

session1

begin

tran

select

*from test1 with(xlock) where id >=

999990

waitfor delay '

00:10:00

'rollback

tran

session 2

use

test;

alter

table test1 add str6 char(20) ;

session 3

use

test;

set nocount on

declare

@iint

set@i=1

;while

@i<=

1000

begin

update test..test1 set id=id-

1where id=

@iset@i=

@i+1print

@iend

microsoft sql server 2005 - 9.00.1399.06 (x64)   oct 14 2005 00:35:21   

有聚集索引

執行順序也按會話 1/2/3 執行;

會話1、先鎖10行(表級別ix鎖,行級別x鎖)

會話2、然後加列(表ix鎖獲取,sch-m 鎖等待)=》結果 等待  lck_m_ix ,被會話1阻塞

會話3、修改非會話1鎖定的10行=》結果等待 lck_m_sch_m   ,被會話2阻塞

sqlserver新增列 字段 描述

id name type date 四個字段,表名是library 姓名 描述資訊 library 表名 被描述字段 name execute sp addextendedproperty n ms description 姓名 n user n dbo n table n library n co...

mycat入門案列

mycat就是乙個加強版的mysql,使用的命令和mysql一樣 mycat有3個主配置檔案 1 schema.xml 定義邏輯庫和邏輯表 2 service.xml 定義了使用者登入資訊 使用者名稱和密碼等 3 rule.xml 定義了分片規則等 首先貼一下我的配置 schema.xml sele...

DHCP應用案列

環境 centos7 需求 讓員工實現0配置即可接入網路,但公司內部的若干檔案伺服器和印表機伺服器需要使用固定的ip 部署dhcp服務很簡單,首先安裝dhcp,yum y install dhcp.然後配置 etc dhcp dhcpd.conf dhcpd.conf default lease t...