MySQL field type

Source: Internet
Author: User

Will install MySQL, will be a few SQL statements, will JDBC, hibernate configuration, thought will be MySQL, in recent days the interview was asked to MySQL problem, shame, systematic study.

One of the MySQL optimizations, select the appropriate rather than the largest data type.

Integral type

Type Bytes occupied Range
TINYINT 1 2^8
SMALLINT 2 2^16
Mediumint 3 2^24
Int 4 2^32
BIGINT 8 2^64

Floating point Type

Type Describe
float[(M,D)] M represents the maximum total number of digits, and D indicates the maximum number of digits after the decimal point
double[(M,D)] Ditto

Date type

Type Range
Year 1970~2069
Time -8385959~8385959
DATE 1000-01-01~9999-12-31
Datetime 1000-01-01 00:00:00~9999-12-31 23:59:59
Datestamp 1970-01-01 00:00:00~2037-12-31 23:59:59

Character type (omit enum type and collection)

Type Range
CHAR (M) Fixed length, m characters 0~255
VARCHAR (M) Variable length, l+1 characters, l<=m,l<=m<=65535
Tinytext Holds up to 2^8 characters
TEXT Holds up to l<2^16 characters
Mediumtext Holds up to l<2^24 characters
Longtext Holds up to l<2^32 characters

MySQL field type

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.