SQLite - SPLessons

SQLite Datatypes

Chapter 5

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQLite Datatypes

SQLite Datatypes

shape Introduction

A Data type is a programming language, which contain set of values and data. SQLite Datatypes defines an appropriate kind of data, like integer, floating-point and Boolean.

SQLite Datatypes also defines the attainable values for that type, the operations that should be possible on that sort and then stores the data.

Datatypes are classified into

String data types

shape Description

In SQLite, a string can control anything from plain text to double data such as files and images. The string can be related and examined based on pattern identity by using the like operators.

The following are the String Data types in SQLite :

Datatype Syntax Maximun Size
CHAR(size) Max Size 255 Characters
VARCHAR(Size) Max Size 255 Characters
TEXT(Size) Max size of 65,535 characters
BINARY(size) Maximum size of 255 characters
VARBINARY(size) Maximum size of 255 characters

Numeric Datatypes

shape Description

Numeric Datatypes in SQLite Datatypes combines number data types, including fixed-point, whole numbers and drifting point. In expansion, SQLite additionally bolsters BIT data sort for putting away field values. Numeric sorts are signed or unsigned with the exception the BIT sort.

The following are the Numeric Datatypes in SQLite.

Datatype Syntax Maximum Size
BIT Very small integer value.
Signed values range from -128 to 127. Unsigned values range from 0 to 255.
FLOAT(p) Floating point number
BOOLEAN Synonym for TINYINT
INT(m) Standard integer value.
Signed values range from -2147483648 to 2147483647. Unsigned values range from 0 to 4294967295.
INTEGER(m) Standard integer value.
Signed values range from -2147483648 to 2147483647. Unsigned values range from 0 to 4294967295.
NUMERIC(m,d) Unpacked fixed-point number.
m defaults to 10, if not specified.
d defaults to 0, if not specified.
DOUBLE(m,d) Double precision floating point number.
DOUBLE PRECISION(m,d) Double precision floating point number

Date/Time Datatypes

shape Description

SQLite produces the sequence for date and time. Besides, SQLite holds timestamps datatype for capturing the adjustments made in the row of table. If one used to store the year past date & month, then utilize YEAR data sort.

The following are the Date/Time Data types in SQLite.

Datatype Syntax Maximum Size Explanation
DATE Values range from ‘1000-01-01’ to ‘9999-12-31’ Displayed as ‘YYYY-MM-DD’
TIME Values range from ‘-838:59:59’ to ‘838:59:59’ Displayed as ‘HH:MM:SS’
YEAR[(2|4)] Year value as 2 digits or 4 digits Default is 4 digits
DATETIME Values range from ‘1000-01-01 00:00:00’ to ‘9999-12-31 23:59:59’. Displayed as ‘YYYY-MM-DD HH:MM:SS’

LARGE OBJECT(LOB) DATA TYPES

shape Description

The following are the LOB Data types in SQLite.

Datatype Syntax Maximum Size
TINYBLOB Maximum size of 255 bytes
BLOB(size) Maximum size of 65,535 bytes
LONGTEXT Maximum size of 4GB or 4,294,967,295 characters

Substantial ordinarily signifies “around 4kb or more”, albeit a few databases can cheerfully handle up to 32kb preceding information turns out to be “extensive”. Huge articles can be either literary or paired in nature. PDO permits to work with the expansive information sort by utilizing the pram_lob code.

Summary

shape Key Points

  • SQLite Datatypes contains set of values and data.
  • String Data type uses char and varchar.
  • Number Data type uses integer and floating values.
  • Date and Time data type uses ‘YYYY-MM-DD’ and ‘HH:MM:SS’.