为什么时间 table 中的结束日期是最大系统时间而不仅仅是 NULL

Why is the end date in a temporal table the maximum system time and not just NULL

我们正在考虑为我们的一些 table 实施双时态解决方案,因为它们必须同时记录应用程序时间和系统时间。

我知道 SQL 2016 仅支持系统时间组件,因此我们将把 table 转换为时间组件并修改我们现在拥有的内容以创建一个功能齐全的双时间组件解决方案。

我的问题是关于一致性。时间 table 的系统时间结束日期组件设置为 9999-12-31 23:59:59.9999999,所以我认为设置我们的 application/valid 时间结束是个好主意日期也为 9999-12-31 23:59:59.9999999.

不过有人问我"Why can't we just set it to NULL to indicate that the period in the main table has no end?"

那是为什么呢?为什么 MS 选择使用 9999-12-31 23:59:59.9999999 而不是 NULL?

它是否像使查询(可能)更易于编写一样简单?我想 BETWEEN 对两个实际日期值的效果更好,但我想不出更多。

这是因为那些列是 Period 列。 (本质上你是对的)由于时间段是时间的定义,因此逻辑上不应将其与 null.This MSSQL 比较时间值和跟踪所有更新的方式进行比较(而不是与null 并且必须假设 null doents 意味着缺少数据但是一个时期的结束。

Period start column: The system records the start time for the row in this column, typically denoted as the SysStartTime column.

Period end column: The system records the end time for the row in this column, typically denoted at the SysEndTime column. MSDN