Home > Database > Mysql Tutorial > body text

What are the MySQL data types? Detailed explanation of MySQL data types

青灯夜游
Release: 2018-10-17 17:55:14
forward
3623 people have browsed it

What are the data types of MySQL? This article will give you a detailed explanation of MySQL data types. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

MySQL data types

MySQL common data types include numerical values, dates and times, and strings

Number

Integer Types (Exact Value)

Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT

int
tinyint
bigint

What are the MySQL data types? Detailed explanation of MySQL data types

Fixed point types ( Fixed-Point Types (Exact Value) - DECIMAL, NUMERICDECIMAL(5,2): 5 represents precision, 2 represents scale; represents This column can store a total of 5 digits, accurate to 2 decimal places; Storage range: -999.99 ~ 999.99

NUMERIC is NUMERIC

Explanation: What is the precision? The decimal point integer digits cannot exceed the previous precision.
decimal(0) The default is decimal(10,0)



Floating-Point type (approximate value)-Floating

Floating-Point Types (Approximate Value) - FLOAT, DOUBLEfloat If you store 4bytesfloat (7,4), you will see a display like this: -999.9999. MySQL performs rounding when storing the value, so if you insert 999.00009 into a floating (7,4) column, the approximate result is 999.0001

If M and D are omitted, values ​​are stored to the limits permitted by the hardware.


double stores 8 bytes
Time and date

    DATE:
  • Date 'YYYY-MM-DD'. The supported range is '1000-01-01' to '9999-12-31'

  • DATETIME:
  • Date time combination 'YYYY-MM-DD HH:MM:SS' The supported range is '1000-01-01 00 :00:00' to'9999-12-31 23:59:59'.

    ##TIMESTAMP:
  • Timestamp '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' Note: It cannot be equal to '1970-01-01 00:00:00' and will return to zero;

    TIME:
  • Time'-838:59:59.000000' to '838:59:59.000000' Note: '11: 12' means '11:12:00', not '00:11:12' ; '1112' and 1112 as meaning '11:12:00; by default, out-of-range values ​​will be automatically converted to close values , eg: '-850:00:00' and '850:00:00' are converted to '-838:59:59' and '838:59:59'; invalid time values ​​will be converted to '00 :00:00'

    YEAR:
  • range 1901 to 2155, or 0000 Note: YEAR(4) and YEAR( 2) The difference lies in the display; eg: 70 (1970 or 2070) or 69 (2069).

    String

CHAR:
  • 0 to 255 fixed length, padded with spaces when storing; delete the following spaces when reading, PAD_CHAR_TO_FULL_LENGTH sql mode enabled

    VARCHAR:
  • 0 to 65,535 variable length

    BLOB:
  • Save large binary data (byte string), no character set, eg: pictures, audio and video, etc.

    TEXT:
  • Saves non-binary strings (strings); there is a character set

    ##BINARY and VARBINARY:

  • Similar to CHAR and VARCHAR; save byte strings, not character strings, which means they have no character set
  • Summary: The above is all of this article Content, I hope it will be helpful to everyone's study. For more related tutorials, please visit mysql database graphic tutorial ,

    MySQL video tutorial
  • ,
bootstrap video tutorial

!

The above is the detailed content of What are the MySQL data types? Detailed explanation of MySQL data types. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template