MySQL Basic beginner learning "2"

Source: Internet
Author: User
Tags time zones

1. Data type: Refers to the data characteristics of columns, stored procedure parameters, expressions, and local variables, which determines the storage format of the data and represents the different types of information

(1) integer type (by storage range): TINYINT (1 bytes) samllint (2 bytes) mediumint (3 bytes) INT (4 bytes) BIGINT (8 bytes)

One of the principles of data optimization: Choosing the most reasonable and appropriate data type, rather than the largest data type. The larger the storage range, the greater the space.

(2) floating point number (by storage range): Single-precision floating-point float [(m,d)] double-precision floating point double[(m,d)];

M: Total number of digits, D: number of digits after the decimal point;m>=d; if M and D are omitted, the value is saved according to the hardware allowable limit. A single-precision floating-point number is accurate to approximately 7 decimal digits.

(3) DateTime type (storage requirement): Year (1) time (3) Date (3) DATETIME (8) TIMESTAMP (timestamp) (4)

Many times we design to date-and-time types, and we tend to be more of a numeric type because of the cross-time zones involved. Later involved in PHP to understand more specifically.

(4) Character type: CHAR (m): M bytes, 0<=m<=255 not reached the specified length, followed by space to store

VARCHAR (M): l+1 bytes, l<=m 0<=m<=65535

tinytext:l+1 bytes, l<2^8

text:l+2 bytes, l<2^16

Mediumtext:l+3 bytes, l<2^24

Longtext:l+4 bytes, l<2^32

ENUM (' value1 ', ' value2 ',...) : 1 or 2 bytes, depending on the number of enumeration values (up to 65,535 values)

SET (' value1 ', ' value2 ',...) : Set, (any combination of these values) 1, 2, 3, 4, or 8 bytes, depending on the number of set members, up to 64 members

These data types can be applied to a data table or to data stored procedures, functions, and so on.

MySQL Basic beginner learning "2"

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.