Sybase Testing Ref - Sybase Identity

Sybase Identity

***********

June 2006

About the tutorial

n To introduce some basic concepts of IDENTITY

n To introduce how to use IDENTITY properly

Basic Concept

n What's IDENTITY

- Auto increment column

n Advantage of IDENTITY

- Auto generated, high efficiency

n Using IDENTITY

- Number leaking

Basic Concept

n DDL in creating TABLE

- ColumnName numeric(N) identity

- with identity_gap = M (optional)

- Default gap is 0, using server setting

- Data type can be INTEGER, and numeric(N), N [1,31]

Basic Concept

n Sample DDL

CREATE TABLE order_main(

order_no NUMERIC(20) IDENTITY

,cust_no NUMERIC(20) NOT NULL

,comments VARCHAR(256) NULL

)

LOCK DATAROWS

WITH IDENTITY_GAP=100

Basic Concept

n Identity Gap

Basic Concept

n Sp_help TableName

- Show which field is identity

- Show the value of identity_gap

- sample

Other Issues

n Only one identity column in a table

n Identity value cannot be reset

n Initial value is always 1

n Manually insert on identity column

- Set identity_insert Table on/off

- session scope

- Only one table with identity_insert on in a session

Other Issues

n @@identity -session scope

n reach maximum value

n Modify identity_gap

- sp_chgattribute "TableName","identity_gap",20

n Modify Global identity_gap

- sp_configure

"identity burning set factor"5000

Other Issues

n Sample DDL

Find table with IDENTITY column:

SELECT name FROM sysobjects WHERE next_identity(name) IS NOT NULL AND type='U'

Change gap:

sp_chgattribute 'cmdm_sign_log','identity_gap',1000

The End

THANKS

98399.html

BeanSoft 2007-02-06 17:56 发表评论
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值