当前位置:数据库 > SYBASE >>

sybase事务、锁、隔离级别

 

1:ASE中有两种事务模式
a: Chained Mode
b:unChained Mode(Sybase默认)
unchained mode显示的开始一个事务,chained隐式的开始一个事务
unchained mode 使用'commint tran', 'rollback tran'
chained mode 使用'commint work ', 'rollback work'
unchained mode 支持嵌套事务,chained mode不支持S y b a s e默认模式是运行在u n c h a i n e d模式,在该模式下,所有事务都必须清楚地以BEGIN TRANSACTION开始,并以R O L L B A C K T R A N S A C T I O N或C O M M I T T R A N S A C T I O N来结尾。

Sybase Adaptive Server在c h a i n e d模式下,允许对有COMMIT TRANSACTION语句而无相应BEGIN TRANTRANSACTION语句的存储过程进行编译。

2:Locking schema
a: All pages table, will lock data and index as they are accessed(可以有clustered index)
b: A Datapages table will lock datpages as they are accessed, index will not be locked(无clustered index)
c: A DataRow table will lock datpages as they are accessed, index will not be locked(无clustered index)

3:Locking type
ASE中最重要的三种lock type是
a:shared locks(select , fetch)
b:update locks(fetch ,update, delete)
c:exclusive locks(insert , update, delete)

4:隔离级别
ASE中一共有四种隔离级别
a:isolation level 0 (read uncommited),允许胀读
b:isolation level 1 (read comminted)(ASE DEFAULT), 不允许胀读
c:isolation level 2 (repeatable read),可重复读
d:isolation level 3 (serializable), 不允许幻影读

sql 代码

?

  1. set?transaction?isolation?level?{0|1|2|3}??
  2. or??
  3. select?...??
  4. at?isolation?{0|1|2|3}??



5:如何编写高效的transaction
For OLTP transaction
a:使transaction尽可能的短
b:使用index来随机访问数据
c:只有在必要的时候才使用transaction
d:选取合适的Lock type和隔离级别
e:使用乐观锁

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,