Temporal Tables (SQL Server 2016) Flashcards
1
Q
What does need a table to be considered as a temporal table?
A
- A primary key constraint.
- Two columns whose date type is DATETIME2 (one for hold the start time, and the other for hold the end time).
Once the table has the previous requirements, then during his creation/alter it needs:
- The start column needs to be marked with the clause GENERATED ALWAYS AS ROW START.
- The end column needs to be marked with the clause GENERATED ALWAYS AS ROW END.
- The declaration clause of the columns pair that denotes the start and end (the previous columns created): PERIOD FOR SYSTEM_TIME (, ).
- The table option SYSTEM_VERSIONING needs to be ON.
- A linked history table, which SQL Server can create in case it doesn’t exist.