PRAGMA encoding
In first form, if the main database has already been created, then this pragma returns the text encoding used by the main database, one of 'UTF-8', 'UTF-16le' (little-endian UTF-16 encoding) or 'UTF-16be' (big-endian UTF-16 encoding).
PRAGMA encoding; PRAGMA encoding = 'UTF-8'; PRAGMA encoding = 'UTF-16'; PRAGMA encoding = 'UTF-16le'; PRAGMA encoding = 'UTF-16be';
On the sample database
What PRAGMA encoding returns on the sample database, in SQLite 3.54.1 as built for the browser by sql.js:
| encoding |
|---|
| UTF-8 |
What the SQLite documentation says
In first form, if the main database has already been created, then this pragma returns the text encoding used by the main database, one of 'UTF-8', 'UTF-16le' (little-endian UTF-16 encoding) or 'UTF-16be' (big-endian UTF-16 encoding). If the main database has not already been created, then the value returned is the text encoding that will be used to create the main database, if it is created by this session.
The second through fifth forms of this pragma set the encoding that the main database will be created with if it is created by this session. The string 'UTF-16' is interpreted as "UTF-16 encoding using native machine byte-ordering". It is not possible to change the text encoding of a database after it has been created and any attempt to do so will be silently ignored.
If no encoding is first set with this pragma, then the encoding with which the main database will be created defaults to one determined by the API used to open the connection.
Once an encoding has been set for a database, it cannot be changed.
Databases created by the ATTACH command always use the same encoding as the main database. An attempt to ATTACH a database with a different text encoding from the "main" database will fail.
From sqlite.org's pragma documentation for SQLite 3.54.1, in the public domain.