SQLite
SQLite Database: How to Create, Open, Backup & Drop Files
SQLite databases are very lightweight. Unlike other database systems, there is no configuration,...
Data types in SQLite are different compared to other database management system. In SQLite, you can declare data types normally, but you still can store any value in any data type.
In this tutorial, you will learn-
SQLite is typed less. There are no data types, you can store any type of data you like in any column. This is called dynamic types.
In static types, like in other database management systems, if you declared a column with a data type integer, you can only insert values of data type integer. However, in dynamic types like in SQLite, the type of the column is determined by the value inserted. And then SQLite stores that value depending on its type.
In SQLite there are different storage methods depending on the type of value, these different storage methods are called storage classes in SQLite.
The following are the storage classes available in SQLite:
Type affinity is the recommended type of data stored in a column. However, you still can store any type of data as you wish, these types are recommended not required.
These types were introduced in SQLite to maximize the compatibility between SQLite and other database management system.
Any column declared in an SQLite database is assigned a type affinity depending on it declared data type. Here the lift of type affinities in SQLite:
Here's how SQLite determines the affinity of the column from its declared data type:
There is also a table on the same page showing some examples for the mapping between SQLite data types and their affinities determined by these rules:
Any column of data type contains the "INT" word, it will be assigned an INTEGER type affinity. It will be stored in an INTEGER storage class.
All the following data types are assigned as an INTEGER type affinity:
INTEGER type affinity in SQLite can hold any assigned integer number (positive or negative) from 1 byte to maximum 8 bytes.
REAL numbers are the number with double floating points precision. SQLite stored real numbers as 8 bytes' array. Here is the list of data types in SQLite that you can use to store REAL numbers:
There is only one way to store large files into a SQLite database, and it is using the BLOB data type. This data type is used to store large files like images, files (from any type), etc. The file is converted into bytes array and then stored in the same size as the input file.
SQLite doesn't have a separate BOOLEAN storage class. However, the BOOLEAN values are stored as INTEGERS with values 0 (as false) or 1 (as true).
You can declare date or date times in SQLite using one of the following data types:
Note that, there is no separate DATE or DATETIME storage class in SQLite. Instead, any values declared with one of the previous data types are stored on a storage class depending on the date format of the inserted value as following:
Summary:
SQLite supports a broad range of data types. But, at the same time, it is very flexible regarding data types. You can put any value type in any data type. SQLite also introduced some new concepts in data types like type affinity and storage classes, unlike other database management systems.
SQLite databases are very lightweight. Unlike other database systems, there is no configuration,...
SQLite supports different types of SQL Joins, like INNER JOIN, LEFT OUTER JOIN, and CROSS JOIN....
$20.20 $9.99 for today 4.6 (119 ratings) Key Highlights of SQLite PDF 159+ pages eBook Designed for...
SQLite offers a lot of different installation packages, depending on your operating systems. It...
Download PDF 1) Explain what is SQLite? SQLite is a mostly ACID compliant relational database...
In this tutorial, you will learn- SQLite constraint Primary Key Not null constraint DEFAULT...