SQLite Forum

Verifying schema for application file format
If you are dealing with "your application" and databases which should have a "known schema", the easiest way to guarantee integrity would be to retrieve the schema in some predictable order and compute a checksum/CRC/hash over it and see if that is what you expect.  For example:

select aggsha3_512(sql) 
  from (
          select sql 
            from sqlite_master 
        order by sql

where aggsha3_512 is a custom aggregate function that (in my case) computes the sha3 512 bit hash over the input.  If the result is what you expect, then the schema contains what you expect since the input order is deterministic.  If it does not match what should be there, then the schema has been tampered with.

Note that since you are doing a sort, changes in the order of the schema table entries will be irrelevant.