{"id":954,"date":"2025-01-10T00:36:16","date_gmt":"2025-01-10T00:36:16","guid":{"rendered":"https:\/\/turtleflyblog.com\/?p=954"},"modified":"2025-01-10T00:36:19","modified_gmt":"2025-01-10T00:36:19","slug":"sql-server-temporal-table","status":"publish","type":"post","link":"https:\/\/turtleflyblog.com\/en\/2025\/01\/10\/sql-server-temporal-table\/","title":{"rendered":"SQL SERVER Temporal Table"},"content":{"rendered":"\n
Temporal Table was added in SQL SERVER 2016. The primary feature of temporal table is to record a table\u2019s history data. Temporal table will record every data that is added, updated or deleted in a table in any movement. The new version of EntityFramework Core also has some Temporal Table functions. Temporal Table primary has these three functions.<\/p>\n\n\n\n
Auditing: <\/strong>For certain industries, such as financial or pharmactural institutions, historical records can be tracked to see if any data has been added or deleted.<\/strong><\/p>\n\n\n\n
History Data Analysis<\/strong>: It is possible to analyze the historical records of a company’s products to determine sales performance, especially during specific time periods. This is also useful for analyzing stock market trends.<\/p>\n\n\n\n
Data recovery<\/strong>: For example, in a bank, if something goes wrong due to misuse, data can be recovered by observing and tracking historical records.<\/p>\n\n\n\n
Example:<\/strong><\/p>\n\n\n\n
Build a table<\/strong><\/p>\n\n\n\n
Build a table with its temporal table. Table schema is shown below\u3002The table\u2019s name is BookInventory. The table has itstemporal table as dbo.BookInventoryHistory\u3002BookInventoryHistory is System-Versioned\u3002”System-Versioned” means that SQL Server can automatically generate and maintain a Historical Table.<\/p>\n\n\n\n