sql查询禁用缓存_如何在SQL Server 2017中启用和禁用身份缓存

sql查询禁用缓存

Every data warehouse developer is likely to appreciate the significance of having surrogate keys as part of derived fields in your facts and dimension tables. Surrogate keys make it easy to define constraints, create and maintain indexes, as well as define relationships between tables. This is where the Identity property in SQL Server becomes very useful because it allows us to automatically generate and increment our surrogate key values in data warehouse tables. Unfortunately, the generating and incrementing of surrogate keys in versions of SQL Server prior to SQL Server 2017 was at times challenging and inconsistent by causing huge gaps between identity values. In this article, we take a look at one improvement made in SQL Server 2017 to reduce the creation of gaps between identity values.

每个数据仓库开发人员都可能会意识到将替代键作为事实和维度表中派生字段的一部分的重要性。 代理键使定义约束,创建和维护索引以及定义表之间的关系变得容易。 这是SQL Server中Identity属性变得非常有用的地方,因为它允许我们在数据仓库表中自动生成和增加代理键值。 不幸的是,在SQL Server 2017之前的版本中,在SQL Server版本中生成和增加代理密钥有时会造成身份值之间的巨大差距,因此充满挑战且不一致。 在本文中,我们看一下SQL Server 2017中所做的一项改进,以减少标识值之间的间隙的创建。

问题 (Problem)

Because versions of SQL Server prior to SQL Server 2016 used a memory cache to keep track of identity values to generate, database corruption or unexpected shutdowns of SQL Server instances led to the creation of gaps between identity values. In order to demonstrate the issue at hand, we make use of the following steps:

由于SQL Server 2016之前SQL Server版本使用内存缓存来跟踪要生成的标识值,因此数据库损坏或SQL Server实例的意外关闭会导致标识值之间产生间隙。 为了演示当前问题,我们使用以下步骤:

Step 1: Create the sample table

步骤1:创建示例表

In this step, we create a table that will store a list of ApexSQL products available for free – a as at the time of writing this article, ApexSQL had 6 products licensed for free. Script 1 shows a create table statement for the [dbo].[ApexSQL_Products] table that will be used to store our product list. Furthermore, the script also indicates that [ProductID] is our surrogate key that makes use of the Identity property.

在此步骤中,我们创建一个表,该表将存储免费提供的ApexSQL产品列表–在撰写本文时,ApexSQL拥有6个免费许可的产品。 脚本1显示了[dbo]。[ApexSQL_Products]表的创建表语句,该语句将用于存储我们的产品列表。 此外,脚本还指示[ProductID]是我们的代理密钥,它使用了Identity属性。

CREATE TABLE [dbo].[ApexSQL_Products]
([ProductID]    INT IDENTI

你可能感兴趣的:(数据库,java,mysql,python,oracle)