MySQL Insert Statement

Data type defines the type of data entered by the user. While defining the fields of table we have to mention proper data type along with its size.

MySQL uses many different data types like: integer, real, date-time, string etc.

Numeric Data Types

Numeric data type contain numeric value without decimal.

Data TypeSizeDescription
TINYINT1 byteRange of -128 to 127 or 0 to 255 unsigned.
SMALLINT2 bytesRange of -32,768 to 32,767 or 0 to 65535 unsigned.
MEDIUMINT3 bytesRange of -8,388,608 to 8,388,607 or 0 to 16,777,215 unsigned.
INT4 bytesRange of -2,147,483,648 to 2,147,483,647 or 0 to 4,294,967,295 unsigned.
BIGINT8 bytesRange of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 or 0 to 18,446,744,073,709,551,615 unsigned.

Decimal Data Type

Decimal data type contain numeric as well as decimal value.

Data TypeSizeDescription
FLOAT4 bytesA small number with a floating decimal point.
DOUBLE[Length, Decimals]8 bytesA large number with a floating decimal point.

Date-Time Data type

Data-Time data type contain date as well as time value.

Data TypeSizeDescription
DATE3 bytesFormat is YYYY-MM-DD.
TIME3 bytesFormat is HH:MM:SS

String Data Type

String data type contain alpha numeric data type.

Data TypeSizeDescription
CHAR[Length]Length bytesA fixed-length from 0 to 255 characters long.
VARCHAR(Length)String length + 1 byteVariable-length strings with a maximum size of 65,535 characters.