Does SQL read all datatypes?


#1

Question

Does SQL read all datatypes?

Answer

SQL is in itself a management language, it does not discriminate what it stores, as a matter of fact, SQL in itself as a language does not know, the difference comes when we talk about database systems that use SQL, some of them require us to declare what type will the data stored will be so it can allocate the necessary memory space for it, some of those systems are MySQL, PostgreSQL, MS access, among others, their most common data types are:

CHAR() which is based on the maximum amount of characters it will be allowed to contain
VARCHAR() which is pretty much like char but for variable size strings, again we can set the maximum amount of characters in between the parenthesis
TEXT has a maximum length of 65,535 characters
INT() any integer number where you can specify the maximum length
FLOAT() alike to INT but with decimals
DOUBLE() if you really need to store a really large number
BLOB if we were to store an array or object. Holds up to 65,535 bytes of data
DATE stores a date in the format YYYY-MM-DD.

The better news is that SQLite is a dynamic type system which means that we do not need to specify the type at the time of creation and if we were and then inserted a value with another type, it will overwrite the requirement to accommodate, yet it does have the following options:

NULL Meaning: missing information or unknown.
INTEGER For whole numbers (either positive or negative). An integer can have variable sizes such as 1, 2,3, 4, or 8 bytes.
REAL For real numbers with decimal values that use 8-byte floats.
TEXT Used to store character data. The maximum length of TEXT is unlimited. SQLite supports various character encodings.
BLOB Just like the other systems it can store any kind of object. The maximum size of BLOBs is unlimited.