I'm trying to implement a methodology to check the integrity of a restored database. It goes as following:
- Create a snapshot of the database.
- Gather various metadata:
- On disk used space.
- Name of tables.
- Number of rows in each tables.
- Generate a cryptographic hash using the data in each table.
My issue goes with the 3rd step to generate the cryptographic hash. I plan to read each row one by one and update my hash with the data they contain. But for my check to match I have to make sure that the row order stays the same.
How can I make sure to always get the same row order, assuming that I don't know upfront the table structure and on what column I can order on.