Mastering Temporal Tables and Versioning Through Practical SQL Exercises
Temporal Tables and Versioning Exercises with solutions [20 exercises with solution]
1. Creating a Temporal Table to Track Historical Data
Write a SQL query to create a temporal table for tracking historical data
2. Querying Current Data from a Temporal Table
Write a SQL query to retrieve current data from a temporal table.
3. Retrieving Historical Data from a Temporal Table
Write a SQL query to retrieve historical data from a temporal table.
4. Retrieving Data as of a Specific Point in Time
Write a SQL query to retrieve data as of a specific point in time using a temporal table.
5. Retrieving all Changes Between Two Points in Time
Write a SQL query to retrieve all changes made to a temporal table between two points in time.
6. Retrieving All Versions of a Specific Row
Write a SQL query to retrieve all versions of a specific row in a temporal table.
7. Disabling System-Versioning on a Temporal Table
Write a SQL query to disable system-versioning on a temporal table.
8. Enabling System-Versioning on an Existing Table
Write a SQL query to enable system-versioning on an existing table.
9. Archiving Old Records from a History Table
Write a SQL query to archive old records from a history table.
10. Restoring a Table to a Previous State Using Temporal Data
Write a SQL query to restore a table to a previous state using temporal data.
11. Adding a New Column to a Temporal Table
Write a SQL query to add a new column to a temporal table.
12. Dropping a Column from a Temporal Table
Write a SQL query to drop a column from a temporal table.
13. Querying the Latest Version of Each Row
Write a SQL query to retrieve the latest version of each row in a temporal table.
14. Migrating Data from a Non-Temporal Table to a Temporal Table
Write a SQL query to migrate data from a non-temporal table to a temporal table.
15. Querying Changes Made by a Specific User
Write a SQL query to retrieve changes made by a specific user in a temporal table.
16. Querying Changes Within a Specific Time Range
Write a SQL query to retrieve changes made within a specific time range in a temporal table.
17. Querying the Duration of Each Row's Validity
Write a SQL query to calculate the duration each row was valid in a temporal table.
18. Identifying Rows with No Changes Over Time
Write a SQL query to identify rows that have not changed over time in a temporal table.
19. Querying the First and Last Versions of Each Row
Write a SQL query to retrieve the first and last versions of each row in a temporal table.
20. Querying Rows That Existed at Any Point During a Specific Period
Write a SQL query to retrieve rows that existed at any point during a specific time period in a temporal table.
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics