什么是序列(Database)?我们什么时候需要它? [英] What is a sequence (Database)? When would we need it?

查看:276
本文介绍了什么是序列(Database)?我们什么时候需要它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们创建一个序列,即使有一个主键?

Why would we create a sequence even if there is a primary key?

推荐答案

主键是表。

主键需要一个唯一的值,它需要来自某处。

The primary key needs a unique value, which needs to come from somewhere.

一些数据库产品的功能,只是创建唯一的值。它只是递增一个值并返回它。特别的事情是:没有事务隔离,所以几个事务不能获得相同的值,增量也不回滚。没有数据库序列,很难生成唯一的递增数字。

The sequence is a feature by some database products which just creates unique values. It just increments a value and returns it. The special thing about it is: there is no transaction isolation, so several transactions can not get the same value, the incrementation is also not rolled back. Without a database sequence it is very hard to generate unique incrementing numbers.

其他数据库产品支持使用递增数自动初始化的列。

Other database products support columns that are automatically initialized with a incrementing number.

还有其他方法为主键创建唯一的值,例如Guids。

There are other means to create unique values for the primary keys, for instance Guids.

这篇关于什么是序列(Database)?我们什么时候需要它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆