In case anyone else is interested, here is the answer from MATLAB technical support:
This [is] a bug in executing PRAGMA queries using 'exec()'.
We will be working on this issue to resolve this bug for the upcoming future releases.
However, there is a workaround for this issue:
- As mentioned in the answer for How to enable foreign key for SQLite database, the issue of PRAGMA statements not getting executed by 'exec()' was fixed for R2016a and later releases.
- Hence, moving to a SQLite JDBC workflow would resolve this issue.
- Please refer to the documentation of SQLite JDBC for Windows for the details of how to set up a data source and connect to an SQLite database using the Database Explorer app or the command line.
- Connecting to a database is mentioned in Step 3. Connect using the Database Explorer app or the command line
- Now, you may proceed with using 'exec()' functions with PRAGMA queries and you shall be able to see expected behaviour.