I need to use SQLite database file as a file for storing information, and I want to store the version of the file in the SQLite database file.
How can I do this? I mean, how to store unique (only one) data in SQLite? I don't want to use store the info by making table for this, as the version info is just one number.
Introduction to SQLite UNIQUE constraint To define a UNIQUE constraint, you use the UNIQUE keyword followed by one or more columns. You can define a UNIQUE constraint at the column or the table level. Only at the table level, you can define a UNIQUE constraint across multiple columns.
A blob is a SQLite datatype representing a sequence of bytes. It can be zero or more bytes in size. SQLite blobs have an absolute maximum size of 2GB and a default maximum size of 1GB. An alternate approach to using blobs is to store the data in files and store the filename in the database.
SQLite arrays are not directly supported as a data type for columns in SQLite databases. In relational databases generally, an array is used to store rows with different key columns as an array dimension that means more than one key for a particular key. But in SQLite we cannot directly implement arrays in SQLite.
For SQLite, which is an embedded database, after all, there's nothing wrong with using a single table for holding a unique value like this.
sqlite> CREATE TABLE AppVersion (version);
sqlite> INSERT INTO AppVersion VALUES('1.0');
sqlite> SELECT * FROM AppVersion;
1.0
sqlite> UPDATE AppVersion SET version='1.1';
sqlite> SELECT * FROM AppVersion;
1.1
It's an embedded database. You expect good performance when you use it, not perfect performance. A single extra table (holding only a single row ever) shouldn't make any difference to any reasonable application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With