MySQL data type

Source: Internet
Author: User

The MySQL data types include:

    • Number type (Numeric type)
    • Date and Time type
    • Type of string (string literal)

One, Number type (Numeric type)

We use M to represent the maximum display width of an integer type, the maximum display width is 255, and the display width is independent of the range the data type can represent.

Numeric types allow UNSIGNED (unsigned, greater than or equal to 0) and signed (Signed, default) properties.

SERIAL is BIGINT UNSIGNED not NULL auto_increment UNIQUE alias, you can create a table like this:

Create TableB (a serial); showCreate Tableb;+-------+----------------------------------------------------------------------------------------------------- ---------------------------------+| Table | Create Table                                                                                                                         |+-------+---------------------------------------------------------------------------------------------------- ----------------------------------+|B| CREATE TABLE' B ' (' A 'bigint( -) unsigned not NULLAuto_increment,UNIQUE KEY' A ' (' a ')) ENGINE=InnoDBDEFAULTCHARSET=Utf8mb4|+-------+----------------------------------------------------------------------------------------------------- ---------------------------------+

BIT (m): M takes a value of 1-64 and defaults to 1.

tinyint[(M)] [UNSIGNED] [zerofill],signed value: 128 to 127,unsigned value: 0 to 255.

BOOL, Boolean: Boolean type, which is synonymous with TINYINT (1). A value of 0 is considered incorrect, and a non-0 value is considered correct. True=1 and False=0, the other values are neither equal to true nor equal to FALSE.

smallint[(M)] [UNSIGNED] [Zerofill]

mediumint[(M)] [UNSIGNED] [Zerofill]

int[(M)] [UNSIGNED] [Zerofill]

integer[(M)] [UNSIGNED] [Zerofill]

bigint[(M)] [UNSIGNED] [Zerofill]

decimal[(M[,d]) [UNSIGNED] [Zerofill]

float[(m,d)] [UNSIGNED] [Zerofill]

double[(m,d)] [UNSIGNED] [Zerofill]

FLOAT (P) [UNSIGNED] [Zerofill]

Two, date and time type

DATE the supported range is ' 1000-01-01 ' to ' 9999-12-31 '. MySQL displays DATE values in ' yyyy-mm-dd ' format.

datetime[(FSP)] fsp:fractional seconds part seconds of the decimal point. The supported range is ' 1000-01-01 00:00:00.000000 ' to ' 9999-12-31 23:59:59.999999 '. MySQL displays DATETIME values in ' yyyy-mm-dd hh:mm:ss[.fraction] ' format

Three, String type

Reference: "refman-5.7" Chapter Data Types

MySQL data type

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.