MySQL-MySQL tutorial

Source: Internet
Author: User
Data types supported by MySQL: bitsCN.com numeric type
MySQL includes strict data types (INTEGER, SAMLLINT, DECIMAL, NUMERIC), and approximate data types (FLOAT, REAL, DOUBLE). after extension, TINYINT is added, MEDIUMINT and BIGINT types have different lengths, and BIT types are added to store BIT data.
In the integer type, different values and storage methods can be divided into five types: tinyint, smallint, mediumint, int, and bigint. For integer data, MySQL supports specifying the display width in parentheses after the type name. for example, int (5) indicates that the display width is filled before the number when the value width is less than 5 characters, if the specified width is not displayed, the default value is int (11 ). Zerofill indicates filling with '0', and filling with the character '0' when there is not enough space for digits.
Date and time type
Mysql supports multiple data types for date and time representation. The main differences between these data types are as follows: (1) if it is used to represent the year, month, and day, it is usually represented by DATE; (2) if it is used to represent the year, month, day, hour, and minute, it is usually represented by DATETIME; (3) if it is only used to represent the hour, minute, and second, it is usually expressed by TIME; (4) if it is necessary to insert or update the date to the current system TIME, it is usually expressed by TIMESTAMP. (5) If it is only a YEAR, YEAR can be used.
Zero values for different DATE types are shown below: data type zero value represents DATETIME0000-00-00 00: 00: 00TIME00: 00: 00 DATE 0000-00-00timestamp000000000000000000year0000
String type
CHAR is similar to VARCHAR, which is used to save short strings in MySQL. The main difference between the two lies in different storage methods: the length of the CHAR column is fixed to the length declared during table creation, and the length can be from 0 ~ Any value of 255, and the value in the VARCHAR column is a variable-length string, the length can be specified as 0 ~ Value between 255. During retrieval, CHAR deletes trailing spaces, while VARCHAR retains these spaces.
BINARY and VAEBINARY are similar to CHAR and VAECHAR. The difference is that they contain BINARY strings. When the BINARY value is saved, fill "0x00" at the end of the value to reach the defined length of the specified field.
ENUM is an enumeration type, and its value range needs to be specified through enumeration when creating a table. However, ENUM only allows you to select a single value from the value set, instead of multiple values at a time. The SET type can be composed of any one or more elements from the allowed values. If the set contains duplicate units, we will take them only once. BitsCN.com

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.