SQL Data Types
SQL Data Types
Data types are used to represent the nature of the data that can be stored in the
database table. For example, in a particular column of a table, if we want to store a
string type of data then we will have to declare a string data type of this column.
Data types mainly classified into three categories for every database.
A list of data types used in MySQL database. This is based on MySQL 8.0.
0 to 65535 characters.
BINARY(Size) It is equal to CHAR() but stores binary byte strings. Its size
is 1.
VARBINARY(Size) It is equal to VARCHAR() but stores binary byte strings. Its
bytes.
characters.
characters.
ENUM(val1, val2, It is used when a string object having only one value, chosen
ENUM list. If you insert a value that is not in the list, a blank
65,535 bytes.
BIT(Size) It is used for a bit-value type. The number of bits per value is
maximum value for the size is 65, and the default value is 10.
true.
MySQL Date and Time Data Types
char(n) It is a fixed width character string data type. Its size can be up
to 8000 characters.
varchar(n) It is a variable width character string data type. Its size can be
up to 8000 characters.
varchar(max) It is a variable width character string data types. Its size can be
up to 1,073,741,824 characters.
text It is a variable width character string data type. Its size can be
nchar It is a fixed width Unicode string data type. Its size can be up to
4000 characters.
nvarchar It is a variable width Unicode string data type. Its size can be up
to 4000 characters.
ntext It is a variable width Unicode string data type. Its size can be up
binary(n) It is a fixed width Binary string data type. Its size can be up to
8000 bytes.
varbinary It is a variable width Binary string data type. Its size can be up
to 8000 bytes.
image It is also a variable width Binary string data type. Its size can be
up to 2GB.
2,147,483,647.
bigint It allows whole numbers between -9,223,372,036,854,775,808 and
9,223,372,036,854,775,807.
-922,337,233,685,477.5808 to 922,337,203,685,477.5807.
3.33 milliseconds.
100 nanoseconds
and does not correspond to real time. Each table may contain
from 1 to 38, and the scale s can range from -84 to 127.
DATE It is used to store a valid date-time format with a fixed length. Its
hh:mm:ss format.
BFILE It is used to store binary data in an external file. Its range goes up to
CLOB It is used for single-byte character data. Its range goes up to 232-1
bytes or 4 GB.
NCLOB It is used to specify single byte or fixed length multibyte national
RAW(size) It is used to specify variable length raw binary data. Its range is up
LONG RAW It is used to specify variable length raw binary data. Its range up to