A time travel With temporal tables Leonel Abreu leonel.abreu@gmail.com https://www.linkedin.com/in/leabreu https://es.linkedin.com/in/leabreu
Our Sponsors If you think, that a SQL Saturday is a nice possibility to learn from and network with fellow SQL Server enthusiasts FOR FREE, I just ask you one thing: Visit the sponsor booths and chat with the sponsors! They are covering the expenses for each and every of you, with is around EUR 60 …
Agenda What’s a Temporal Table? It’s useful for A Short “How to” Advantages and how to use it It’s useful for Auditing efects Disaster Recovery Trending Analytics A Short “How to” Scenario and demo
What is a temporal table? Also known as System Versioned Because keep changes Just two extra columns To define periods Finally a second table Which contains the history
How does it work? Source: https://msdn.microsoft.com/en-us/library/dn935015.aspx
How does it work? Source: https://msdn.microsoft.com/en-us/library/dn935015.aspx
Advantages Security Easy to maintain Can be used Is not possible to modify the historical data Easy to maintain Additional coding to insert/update/delete data is not required Can be used For new tables For existing tables
Why temporal tables? Auditing Time Travel Recovering All data changes and forensics if necessary Time Travel State of data as of any time in the past Recovering From accidental data changes, as undesired DELETE operations
Why temporal tables? Calculate Also BI Schema included Trends over time Also BI Can be used to do SCD Schema included If the table structure is changed, it is also recorded
Why temporal tables? Real data sources are dynamic 9/4/2018 7:12 PM Why temporal tables? Real data sources are dynamic Historical data may be critical to business success Traditional databases fail to provide required insights Workarounds are… Complex, expensive, limited, inflexible, inefficient SQL Server 2016 makes life easy No change in programming model New Insights © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Why temporal tables? Azure SQL Database Facts: Solution: Microsoft Ignite 2015 9/4/2018 7:12 PM Why temporal tables? Facts: History is much bigger than actual data Retained between 3 and 10 years “Warm”: up to a few weeks/months “Cold”: rarely queried SELECT * FROM Department FOR SYSTEM_TIME AS OF '2010.01.01' Azure SQL Database Solution: history as a stretch table: PeriodEnd < “Now - 6 months” © 2015 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
How to implement it? Source: https://msdn.microsoft.com/en-us/library/dn935015.aspx
How to implement it?
Query Clauses AS OF FROM TO SysStartTime SysStartTime <= date_time SysEndTime > date_time FROM TO SysStartTime < end_date_time SysEndTime > start_date_time
Query Clauses BETWEEN AND CONTAINED IN ALL SysStartTime <= end_date_time SysEndTime > start_date_time CONTAINED IN SysStartTime >= end_date_time SysEndTime <= start_date_time ALL Returns the union between the current and history table
Schaumamal SVT
Q & A
Please give us feedback! How did you like it? Please give us feedback! to the event: www.sqlsaturday.com/579/eventeval.aspx to me as a speaker: www.sqlsaturday.com/579/sessions/sessionevaluation.aspx
Ressources SQL Server 2016 in 15 Minuten SQL PASS Austria Homepage https://channel9.msdn.com/Series/SQLServer-2016-in-15-Minuten SQL PASS Austria Homepage http://austria.sqlpass.org SQL PASS Austria Meeting Archive http://sdrv.ms/ZFVdnM
Thank You! If you think, that a SQL Saturday is a nice possibility to learn from and network with fellow SQL Server enthusiasts FOR FREE, I just ask you one thing: Visit the sponsor booths and chat with the sponsors! They are covering the expenses for each and every of you, with is around EUR 60 …