Chapter II Introduction to MySQL data types

Source: Internet
Author: User

Chapter II Introduction to MySQL data types


· first section: integer type, floating-point type, and fixed-point number type

Integral type:

· TinyInt (1 bytes)

· SmallInt (2 bytes)

· mediumint (3 bytes)

· Int and Integer (4 bytes )

· BigInt (8 bytes )

Floating point and fixed point number:

· Float (4 bytes)

· Double (8 bytes )

· Decimal (m,d) < fixed number >(M = total length < include decimal point >,d indicates the number of decimal digits)

· section II: Date and Time Types

· Year (1 bytes )

· Date (4 bytes )

· Time (3 bytes )

· DateTime (8 bytes )

· TimeStamp (4 bytes )

      section III: String type

    • char (M)     M bytes     m< /span> is an integer between 0 -255 .

    • varchar (m)   m byte     M The integer length between 0-65535 is variable.

    • text Series string types.

    • tinytext     (0-255 bytes ) .

    • text       (0-65535 bytes .

    • mediumtext (0-167772150 bytes .

    • longtext (0-4294967295 bytes .  

Remark:UTF-8: A chinese character = 3 bytes, English is a byte;

GBK : one kanji = 2 bytes, English is a byte.  

· section Fourth: binary type

· binary (m) m is a byte allowed length of 0-m .

· varbinary (m) m is a byte allowed length of 0-m .  

Note: If you are unable to differentiate the representation range of individual integers, you can view the information by viewing the system help for MySQL .  

       ?  MySQL > Help Contents;

       ? mysql> help Data Types;

       ? mysql> help int;

remark: when the decimal precision is required to be very high, a decimal is preferred, usually representing the amount.

Note: Each date and time data type has a range of values, and if the value inserted exceeds the range of values for that type, the default value is inserted.

? If you want to represent a month or date, you will typically use date
? If you want to represent the day of the month and seconds, you will typically use datetime
If you need to insert or update the current system time regularly, you will typically use the timestamp type
? If you want to represent a minute or seconds, you typically use the time
? If you want to represent a year, you would typically use the years because that type takes up less space than date

Note: These two and the preceding char and varchar types, the difference is Char this group stores character data,binary can store binary data ( pictures, music, videos ).


List of attachments

    Chapter II Introduction to MySQL data types

    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.