SQL datitepes lengths?

I am completely new to SQLite (actually 5 minutes ago), but I know several Oracle and MySql resources.

Question I am trying to find out the lengths of each of the data types supported by SQLite, such as the differences between bigint and smallint. I searched the SQLite documentation (talking only about proximity, only ), SO streams, google ... and found nothing.

My guess . I revised the SQL92 specifications a bit, which talks about data types and its relationships, but not about its lengths, which is pretty obvious. However, I came up with the specifications of Oracle and MySql datatypes, and the indicated lengths are in most cases identical for integers. Should I assume that SQLite uses the same length?

Beyond the question : Am I missing something about SQLite docs? Or am I missing something about SQL in general? Asking for this because I cannot understand why SQLite docs do not specify something basic like datatypes lengths. It just doesn't make sense to me! Although I'm sure there is a simple command for finding lengths ... but why not write them down in documents?

Thanks!

+4
source share
4 answers

SQLite is a little strange when it comes to field types. You can store any type in any field (IE put blob in an integer field). How it works for integers: it depends.

While your application can use a long one (64 bits) to store the value, if it is really <128, then SQLite will use only one byte to save it. If the value> = 128 and <16384, then it will use 2 bytes. The algorithm (as I recall) is that it uses 7 bits of each byte with the eighth bit used to indicate the need for another byte. This works very well for values ​​without negative values, but results in all negative values ​​taking up 9 bytes to store.

+13
source

There are no lengths in SQLite data types; values ​​have lengths. The column that you define as TINYINT may contain a BLOB or vice versa.

+8
source

I am completely new to SQLite documentation, but found it in less than 30 seconds.

Data Types In SQLite Version 3

+5
source

INTEGER. The value is a signed integer stored in 1, 2, 3, 4, 6, or 8 bytes, depending on the value.

8 bytes β†’ mix size: 9223372036854775807

0
source

Source: https://habr.com/ru/post/1304937/


All Articles