DB2如何实现字段的自动增一,一定要救救我,真的散分

michael_yi 2001-12-12 01:24:19
在oracle中有sequence,在sqlserver中有identity(应该也是完成相同功能的吧?),我不太想使用trigger来完成,是否还有直接的或其他的方法类似identity?我是db2新手,希望能给我解释详细一些。不胜感激.

...全文
133 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
michael_yi 2001-12-13
  • 打赏
  • 举报
回复
我想给netyao(笑一笑:-) ),levin_li(levin)分,但怎么也找不到怎么给分,我以前给过的,但现在怎么找不到了。急死我了。
netyao 2001-12-12
  • 打赏
  • 举报
回复
When connected to a DB2 version 7.1 or higher database, ei-O uses the IDENTITY property to replicate the functionality of Access AutoNumber fields. The "GENERATED ALWAYS AS INDENTITY (START WITH x, INCREMENT BY y, CACHE z)" usage is specified when new DB2 tables are created and either the Access table contains no data or the "Data" option is not checked. In all other cases, "GENERATED BY DEFAULT AS IDENTITY (START WITH x, INCREMENT BY y, CACHE z)" is used.

The START WITH value can be any positive or negative value that could be assigned to this column. The default is 1.

The INCREMENT BY parameter cannot be zero or exceed the value of a large integer. The default is 1.

The CACHE value must be in the range of 2 to 32,767 and defaults to 20. Set the CACHE to 0 for NO CACHE.

netyao 2001-12-12
  • 打赏
  • 举报
回复
When connected to a DB2 version 7.1 or higher database, ei-O uses the IDENTITY property to replicate the functionality of Access AutoNumber fields. The "GENERATED ALWAYS AS INDENTITY (START WITH x, INCREMENT BY y, CACHE z)" usage is specified when new DB2 tables are created and either the Access table contains no data or the "Data" option is not checked. In all other cases, "GENERATED BY DEFAULT AS IDENTITY (START WITH x, INCREMENT BY y, CACHE z)" is used.

The START WITH value can be any positive or negative value that could be assigned to this column. The default is 1.

The INCREMENT BY parameter cannot be zero or exceed the value of a large integer. The default is 1.

The CACHE value must be in the range of 2 to 32,767 and defaults to 20. Set the CACHE to 0 for NO CACHE.

levin_li 2001-12-12
  • 打赏
  • 举报
回复
Create Table table_name
(
SERIALNO BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH +1 , INCREMENT BY +1 , NO CACHE ),
.....
)
panther_totem 2001-12-12
  • 打赏
  • 举报
回复
没有用过,不知道,可以找一找。
netyao 2001-12-12
  • 打赏
  • 举报
回复
我找一找
michael_yi 2001-12-12
  • 打赏
  • 举报
回复
to superjj2002():
有一次你给别人回答过此类问题,但我没弄明白是怎么回事。能给我再回答一次吗?
michael_yi 2001-12-12
  • 打赏
  • 举报
回复
IronPromises(铁诺)哪里去了?数据库高手吧。帮帮我。
michael_yi 2001-12-12
  • 打赏
  • 举报
回复
db2高手,快来帮帮我,只要有价值,一定给分。

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧