MySQL Common data types

Source: Internet
Author: User
Tags time and date

MySQL commonly used data types are numeric type, text type, binary type, and time date.

1. Numeric type

Data type Description
BIT (M) Bit type. m specified number of bits, default value 1, Range 1-64
TINYINT [Unsigned][zerofill] The signed range is-128-127. unsigned 0-255
Bool,boolean Use 0 or 1 to indicate true or false
SMALLINT [Unsigned][zerofill] 2 of the 16-time Square
INT [Unsigned][zerofill] 2 of the 32-time Square
BIGINT [Unsigned][zerofill] 2 of the 64-time Square
Floar (M,D) [Unsigned][zerofill] m specifies the display length, d refers to the number of decimal digits
DOUBLE (M,D) [Unsigned][zerofill] A decimal that represents a greater precision than float

2. Text type

Data type Description
CHAR (size) Fixed-length strings
VARCHAR (size) Variable-length strings
TEXT (CLOB) Large text

Example:

Create Table Student (        int,        varchar)        ,Char(  - ));           

In the above example, the type of name is varchar. When the input character length is less than 20 o'clock, the name is less than 20, and when the input character length is greater than 20 o'clock, an error is entered.

Class is of type char and has a length of 20 and an error when the input length is greater than 20 o'clock.

There are altogether four types of text

Type Memory size
Tinytext 255B
TEXT 64K (Common)
Mediumtext 16M
Longtext 4G

3. Binary type

Type Description
Blob Used to store binary data such as Picture/music

Four types of BLOBs

Type Memory size
Tinyblob 255B
Blob 34.
Mediumblob 16M
Longblob 4G

4. Time and Date type

Type Description
DATE Expression range: ' 1000-1-1 ' to ' 9999-12-31 ' 3 bytes
Datetime Indication range: ' 1000-1-1 00:00:00 ' to ' 9999-12-31 23:59:59 ' 8 bytes
TIMESTAMP Timestamp, which can be used to automatically record the time of INSERT, update operation

MySQL Common 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.