1.

MySQL DATA TYPES

Answer»

In MySQL just like other programming languages, each column, local variable, expression, and parameter has a related data type. A data type is an attribute that specifies the type of data that the object can hold.

  • String Data Types
DATATYPEDETAILS
CHAR(size)Stores Alpha Numeric and special characters. Size varies from 0 to 255 characters.
VARCHAR(size)Can contain letters, numbers, and characters that are of variable length (size). The size parameter specifies the column length in characters; it can be from 0 to 65535.
BINARY(size)Similar to CHAR(). But it stores binary strings.
VARBINARY(size)Similar to Binary() but the length is variable.
TINYBLOBFor Binary Large Objects. Max size=255 bytes.
TINYTEXTHolds string of max length 255 characters.
TEXT(Size)Stores a string of max length 65535 bytes.
BLOBStores Binary Large Objects up to 65535 bytes of data.
MEDIUMTEXTStores 2^8 times the characters as compared to TINYTEXT.
MEDIUMBLOBStores 2^8 times bytes as compared to TINYBLOB.
LONGTEXTStores 2^8 times the characters as compared to MEDIUMTEXT.
LONGBLOBStores 2^8 times bytes as compared to MEDIUMBLOB.
ENUM(val1, val2, val3, ...)Stores only one value, which can be chosen from a range of possible values. An ENUM list can contain at most 65535 values. A value that is inserted that is not in the list will be replaced with a blank value. The values are arranged in the order you specify them.
SET(val1, val2, val3, ...)Stores a string object that can have 0 or more values, chosen from a list of possible values. You can list up to 64 values in a SET list
  • Numeric Data Types
DATATYPEDETAILS
BIT(size)        Stores a bit-value. The size parameter specifies the number of bits per value . The value is represented as a number of bits. The size parameter can hold a value from 1 to 64. The default value for size is 1.
TINYINT(size)Stores very small int values. Signed ranges  from -128 to 127. Unsigned ranges from 0 to 255. Size defines the maximum display width of 255.
BOOLZero is considered as false and one is considered as true.
BOOLEANSame as BOOL.
SMALLINT(size)Stores a small integer. Signed ranges from -32768 to 32767. Unsigned ranges from 0 to 65535. Size defines the maximum display width of 255.
MEDIUMINT(size)Stores a medium valued integer. Signed ranges from -8388608 to 8388607. Unsigned ranges from 0 to 16777215. Size defines the maximum display width of 255.
INT(size)Stores a medium integer. Signed ranges from -2147483648 to 2147483647. Unsigned ranges from 0 to 4294967295. Size defines the maximum display width of 255.
INTEGER(size)Same as INT(size)
BIGINT(size)Stores a large valued integer. Signed ranges  from -9223372036854775808 to 9223372036854775807. Unsigned ranges  from 0 to 18446744073709551615. Size defines the maximum display width of 255.
FLOAT(size, d)Stores a floating point(decimal number). The number of digits is specified in size. The number of digits after the decimal point is specified by the value d.
FLOAT(p)Stores a floating point(decimal number. If p value is between 0 and 24, the data type becomes FLOAT() else the data type becomes DOUBLE()
DOUBLE(size, d)Stores a  normal-size floating point (decimal)number. The number of digits is specified in size. The number of digits after the decimal point is specified by the value d.
DECIMAL(size, d)An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0.
  • Date and Time Data Types
DATATYPEDETAILS
DATEStores a date in the format: YYYY-MM-DD. Supports a range between '1000-01-01' to '9999-12-31'
DATETIME(fsp)Combination of date and time in the format: YYYY-MM-DD hh:mm:ss. Supports a range between '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. 
TIMESTAMP(fsp)Stores a time stamp in the format YYYY-MM-DD hh:mm:ss UTC. Supports a range between '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC. 
TIME(fsp)Stores time in the format hh:mm:ss. Supports a range between '-838:59:59' to '838:59:59'
YEARStores a year in four-digit format. Supports a range between 1901 to 2155 (includes 0000).



Discussion

No Comment Found