When creating a new table, we need to specify the data type
for each column we want there to exist in the table. A data type
is simply a specification of what kind of data is stored in that column. Take a look at the CREATE TABLE
statement below.
In the statement, id
and age
store integer data, name
and joiningDate
store text data, resume
stores a file, and graduationPercentage
stores decimal values. The data types against them show similar values.
Here are a few valid data types in SQLITE
, the database this course runs on.
INTEGER | Stores values that are integer in nature |
REAL | Stores floating point numbers/decimal numbers |
TEXT | Stores character data |
BLOB | Stores binary large objects, like files |
NULL | When the data type is not clear |
Other databases like MySQL
and PostgreSQL
have many similar to this and many other data types, sometimes many specializations of a single kind like INTEGER
and TEXT
. For example, MySQL
supports INT
, TINYINT
, SMALLINT
, MEDIUMINT
and BIGINT
as different variations for INTEGER
, and VARCHAR
, TEXT
for various kinds of texts.