我目前正在学习SQL Server 2016中引入的新功能"系统版本时间表"。然而,对于"GENERATED ALWAYS AS ROW START/END"和"PERIOD FOR SYSTEM_TIME"的确切含义和用法,我有些困惑,这两者都是系统版本时间表所必需的。
可以有人解释一下吗?非常感谢您提供的任何帮助!
CREATE TABLE dbo.Employees
(
empid INT NOT NULL CONSTRAINT PK_Employees PRIMARY KEY NONCLUSTERED,
empname VARCHAR(25) NOT NULL,
department VARCHAR(50) NOT NULL,
salary NUMERIC(10, 2) NOT NULL,
sysstart DATETIME2(0) GENERATED ALWAYS AS ROW START HIDDEN NOT NULL,
sysend DATETIME2(0) GENERATED ALWAYS AS ROW END HIDDEN NOT NULL,
PERIOD FOR SYSTEM_TIME(sysstart, sysend),
INDEX ix_Employees CLUSTERED(empid, sysstart, sysend)
)
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = dbo.EmployeesHistory)
);
UPDATE
操作仍会导致历史记录行被添加,对架构/表格设计的更改非常痛苦,几乎不可能编辑历史记录等等。 - Dai