为什么要在oracle中按顺序使用缓存和顺序?

Why should i use cache and order in sequence in oracle?

我是数据库新手。我一直在阅读 oracle 中的序列。我开始了解顺序子句。我应该引用段落

Specify ORDER to guarantee that sequence numbers are generated in order of request. This clause is useful if you are using the sequence numbers as timestamps. Guaranteeing order is usually not important for sequences used to generate primary keys.

ORDER is necessary only to guarantee ordered generation if you are using Oracle Database with Real Application Clusters. If you are using exclusive mode, sequence numbers are always generated in order

我一点都不明白。 Link 该网站是 a link! 有人可以帮我吗? 如有语法错误请见谅

ORDER 子句顺序仅在 RAC.

中有意义

无论哪个实例收到请求,都保证序列的生成是有序的。

如果您不使用 ORDER 那么为了说明,假设一个序列用 cache=20 定义。实例 1 在其缓存中具有序列值 1 到 20。实例 2 在其缓存中具有序列值 21 到 40。通常,并发会话可能会按以下顺序生成序列值:1、2、21、3、22、4、23 和 24.but 以及 ORDER 子句,此值将为 1、2、3、4 ,5,6,7,..

因此,文档中提到,如果sequence的目的是生成唯一值,则不需要ORDER,但如果在RAC中使用sequence来定义时间顺序,则需要ORDER

Cache: 如果指定Cache序列为20则oracle取20个值一串放入SGA,数据字典更新一次.因此,如果你想使用 35 个序列值,那么在 NO CACHE 的情况下,数据字典将只有 2 次更新,从而提高数据字典中 35 次更新的性能。缓存用于提高序列的性能。而且在数据库关闭时,您将丢失未使用的缓冲序列值。

希望,会有用。

干杯!!

用于保证每条记录获得唯一值的序列。如果您指定 ORDER 属性,那么它还保证在较早时间点创建的记录的序列号低于稍后创建的记录。 在大多数情况下,不需要 ORDER。