DATATYPES IN SQL
The datatype is a guideline for
SQL to understand what type of
data is expected inside each
column.
There are different types of
datatypes:
1. STRING DATA TYPE
CHAR() VARCHAR() TEXT()
A fixed length A variable length It holds a string
string (can string. Has with maximum
contain maximum of length of 65,535
letters,special 8000. bytes.
characters). Ex: varchar(25)
Ex: char(5)
2. NUMERIC DATA TYPES
INT() : It contains standard integer [Link]
occupies 4 bytes of storage.
BIGINT() : It contains large integer numbers. It
occupies 8 bytes of storage.
SMALLINT() : It contains small integer numbers.
It occupies 2 bytes of storage.
3. DATE AND TIME DATA TYPE
DATE() : Stores the data of date.
FORMAT (year,month,day).
TIME() : Stores the data of time.
FORMAT (hour,minute,second).
DATETIME() : Stores both the data of date and
time.
4. BINARY DATA TYPE
Binary() : Fixed length binary data which has
maximum length of 8000 bytes.
VARBINARY() : Variable length binary data.
5. BOOLEAN DATA TYPE
The Boolean data types are used to store logical
values ,typically TRUE or [Link] used for flag
fields to check condition.
6. SPECIAL DATA TYPES
XML() : Used to store XML data and
manipulate XML structure in database.
SPATIAL DATA TYPE() : Stores planar spatial
data such as points,lines and geometry in
database table.