DATATYPES



MySQL - Datatypes


A data type is an attribute that specifies the type of data that the object can hold string, numeric, date/time, and large object datatypes in MySQL.


String Datatypes :


DatatypeSizeDescription
CHAR(size)Maximum size of 255 characters.Where size is the number of characters to store. Fixed-length strings. Space padded on right to equal size characters.
VARCHAR(size)Maximum size of 255 characters.Where size is the number of characters to store. Variable-length string.
TINYTEXT(size)Maximum size of 255 characters.Where size is the number of characters to store.
TEXT(size)Maximum size of 65,535 characters.Where size is the number of characters to store.
MEDIUMTEXT(size)Maximum size of 16,777,215 characters.Where size is the number of characters to store.
LONGTEXT(size)Maximum size of 4GB or 4,294,967,295 characters.Where size is the number of characters to store.
BINARY(size)Maximum size of 255 characters.Where size is the number of binary characters to store. Fixed-length strings. Space padded on right to equal size characters.
VARBINARY(size)Maximum size of 255 characters.Where size is the number of characters to store. Variable-length string.

Numeric Datatypes :


DatatypeSizeDescription
BITVery small integer value that is equivalent to TINYINT(1).Signed values range from -128 to 127.Unsigned values range from 0 to 255.-
TINYINT(m)Very small integer value.Signed values range from -128 to 127. Unsigned values range from 0 to 255.-
SMALLINT(m)Small integer value.Signed values range from -32768 to 32767. Unsigned values range from 0 to 65535.-
MEDIUMINT(m)Medium integer value.Signed values range from -8388608 to 8388607. Unsigned values range from 0 to 16777215.-
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.This is a synonym for the INT datatype.
BIGINT(m)Big integer value.Signed values range from -9223372036854775808 to 9223372036854775807. Unsigned values range from 0 to 18446744073709551615.-
DECIMAL(m,d)Unpacked fixed point number.m defaults to 10, if not specified.d defaults to 0, if not specified.Where m is the total digits and d is the number of digits after the decimal.
DEC(m,d)Unpacked fixed point number.m defaults to 10, if not specified.d defaults to 0, if not specified.Where m is the total digits and d is the number of digits after the decimal.
NUMERIC(m,d)Unpacked fixed-point number.m defaults to 10, if not specified.d defaults to 0, if not specified.Where m is the total digits and d is the number of digits after the decimal.This is a synonym for the DECIMAL datatype
FIXED(m,d)Unpacked fixed-point number.m defaults to 10, if not specified.d defaults to 0, if not specified.Where m is the total digits and d is the number of digits after the decimal.This is a synonym for the DECIMAL datatype.
FLOAT(m,d)Single precision floating point number.Where m is the total digits and d is the number of digits after the decimal.
DOUBLE(m,d)Double precision floating point number.Where m is the total digits and d is the number of digits after the decimal.
DOUBLE PRECISION(m,d)Double precision floating point number.Where m is the total digits and d is the number of digits after the decimal.This is a synonym for the DOUBLE datatype.
REAL(m,d)Double precision floating point number.Where m is the total digits and d is the number of digits after the decimal.This is a synonym for the DOUBLE datatype
FLOAT(p)Floating point number.Where p is the precision.
BOOLSynonym for TINYINT(1)Treated as a boolean data type where a value of 0 is considered to be FALSE and any other value is considered to be TRUE.
BOOLEANSynonym for TINYINT(1)Treated as a boolean data type where a value of 0 is considered to be FALSE and any other value is considered to be TRUE

Date/Time Datatypes :


DatatypeSizeDescription
DATEValues range from '1000-01-01' to '9999-12-31'.Displayed as 'YYYY-MM-DD'.
DATETIMEValues range from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.Displayed as 'YYYY-MM-DD HH:MM:SS'.
TIMESTAMP(m)Values range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.Displayed as 'YYYY-MM-DD HH:MM:SS'.
TIMEValues range from '-838:59:59' to '838:59:59'.Displayed as 'HH:MM:SS'.
YEARYear value as 2 digits or 4 digits.Default is 4 digits.

Large Object (LOB) Datatypes :


DatatypeSizeDescription
TINYBLOBMaximum size of 255 bytes.-
BLOB(size)Maximum size of 65,535 bytes.Where size is the number of characters to store
MEDIUMBLOBMaximum size of 16,777,215 bytes-.
LONGTEXTMaximum size of 4GB or 4,294,967,295 characters-.


MySQL TRIGGERS

MySQL - Triggers

posted on 2019-11-29 21:44:07 - mysql Tutorials


Grant_ Revoke Privilege

MySQL - Grant_ Revoke Privilege

posted on 2019-11-26 23:15:04 - mysql Tutorials


MySQL Vs SQL

MySQL Vs SQL

posted on 2019-11-25 05:02:26 - mysql Tutorials


how to use range in golang

how to use range in golang

posted on 2022-05-03 08:28:11 - Go lang Tutorials


find variable type in golang

find variable type in golang

posted on 2022-05-03 05:24:55 - Go lang Tutorials


for loops in golang

for loops in golang

posted on 2022-05-03 04:27:40 - Go lang Tutorials