Common MySQL Data Types

Source: Internet
Author: User
Tags php mysql

Common MySQL Data Types

The following describes some common data types used in the MySQL database.

1. Integer

Data Type Storage space Description Value Range
TINYINT 1 byte Very small integer Signed value:-128 ~ 127
Unsigned value: 0 ~ 255
SMALLINT 2 bytes Small integer Signed value:-32768 ~ 32767
Unsigned value: 0 ~ 65535
MEDIUMNT 3 bytes An integer of medium size Signed value:-8388608 ~ 8388607
Unsigned value: 0 ~ 16777215
INT 4 bytes Standard integer Signed value:-2147483648 ~ 2147483647
Unsigned value: 0 ~ 4294967295
BIGINT 8 bytes Big integer Signed value:-263 (-9223372036854775808 )~ 263-1 (9223372036854775807)
Unsigned value: 0 ~ 2 ^ 63-1 (9223372036854775807)

2. Floating Point

Data Type Storage space Description Value Range
FLOAT 4 bytes Single-precision floating point number  
DOUBLE 8 bytes Double-precision floating point number  
DECIMAL (M, D) Custom In string format  

3. string type

Type Storage space Description Maximum length
Char [(M)] MB bytes Fixed Length string MB bytes
Varchar [(M)] L + 1 byte Variable Length string MB bytes
Tinyblog, tingtext L + 1 byte Very small blob and text string 28 characters
Blog, text L + 2 bytes Small BLOB and text string 216-1 bytes
Mediumblob, mediumtext L + 3 bytes Moderate BLOB and text string 224 bytes
Longblob, longtext L + 4 bytes Large BLOB and text string 232-1 bytes
Enum ('value', 'value ') 1 or 2 bytes Enumeration: You can assign an enumeration member. 65535 members
Set ('value', 'value ') 1, 2, 3, 4, or 8 bytes Set: You can assign multiple set members. 64 members

4. Date and Time types

Type Storage space Description Maximum length
Date 3 bytes YYYY-MM-DD format Representation 1000-01-01 ~ 9999-12-31
TIME 3 bytes Hh: mm: ss format indicates the time value -838: 59: 59 ~ 838: 59: 59
DATETIME 8 bytes YYYY-MM-DD hh: mm: ss format  
TIMESTAMP 4 bytes The format of YYYYMMDDhhmmss indicates the timestamp.  
YEAR 1 byte Year Value in YYYY format 1901 ~ 2155

Articles you may be interested in
  • Methods for resetting the auto-increment start value of various MySQL Data Table types
  • Navicat for mysql remote connection to the mySql database prompt 10061,1045 error Solution
  • Php mysql database operations
  • MySQL database connection
  • Mysql Server master-slave Database Synchronization Configuration
  • Optimize paging SQL statements for large data volumes in MySQL
  • MySQL large data volume quick insert method and statement Performance Optimization
  • Improves the query speed of millions of data records for MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.