w3resource

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

Click me to see the solution

2. Querying Current Data from a Temporal Table

Write a SQL query to retrieve current data from a temporal table.

Click me to see the solution

3. Retrieving Historical Data from a Temporal Table

Write a SQL query to retrieve historical data from a temporal table.

Click me to see the solution

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.

Click me to see the solution

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.

Click me to see the solution

6. Retrieving All Versions of a Specific Row

Write a SQL query to retrieve all versions of a specific row in a temporal table.

Click me to see the solution

7. Disabling System-Versioning on a Temporal Table

Write a SQL query to disable system-versioning on a temporal table.

Click me to see the solution

8. Enabling System-Versioning on an Existing Table

Write a SQL query to enable system-versioning on an existing table.

Click me to see the solution

9. Archiving Old Records from a History Table

Write a SQL query to archive old records from a history table.

Click me to see the solution

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.

Click me to see the solution

11. Adding a New Column to a Temporal Table

Write a SQL query to add a new column to a temporal table.

Click me to see the solution

12. Dropping a Column from a Temporal Table

Write a SQL query to drop a column from a temporal table.

Click me to see the solution

13. Querying the Latest Version of Each Row

Write a SQL query to retrieve the latest version of each row in a temporal table.

Click me to see the solution

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.

Click me to see the solution

15. Querying Changes Made by a Specific User

Write a SQL query to retrieve changes made by a specific user in a temporal table.

Click me to see the solution

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.

Click me to see the solution

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.

Click me to see the solution

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.

Click me to see the solution

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.

Click me to see the solution

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.

Click me to see the solution

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.



Follow us on Facebook and Twitter for latest update.