MySQL basic note (vi)-data type one

Source: Internet
Author: User

Data type (column type)

  The so-called data is strong, is a unified classification of data. From the system point of view, in order to be able to use a unified approach to management, better use of limited space.

The data types in SQL are divided into three main categories: 1, numeric type, 2, String type, and time date type.

  

First, the numerical type

  Numeric data, which are numeric values.

The numerical model is divided into integer and fractional type.

  integer type: storing integer data, in SQL to save disk space, the system will be shaped and subdivided into 5 categories.

Tinyint: Mini integer with a byte storage representing a maximum of 256 states. Common

Smallint: Small integer, using 2 bytes of storage, indicates that the state is the most 65536.

Mediumint: Medium integer with 3 bytes of storage.

INT: Standard type with 4 bytes of storage. Common

Bigint: Large integer with 8 bytes of storage.

integer data insertion can only insert an integral type within a range.

Use unsigned data to limit the data type to unsigned;

  

Decimal Type:   numeric type with a decimal point or range beyond the integer type.

SQL divides the decimal type into two types: floating-point and fixed-point

Floating point: is a precision data that is expected to lose precision (auto-rounding) after a specified range is exceeded.

Theoretically divided into two kinds of precision: float, single-precision, occupies 4 bytes of storage, the accuracy range of about 7 bits. Double, doubles, consumes 8 bytes of storage.

  

Floating-point numbers are bound to be rounded (exceeding the precision range), and the system is allowed to be established because the system only causes the integer portion to exceed the specified length.

Fixed-point type: Absolute guarantee that the integer part will not be rounded, the fractional part is possible (theoretically no loss of precision, theoretically?). )

  

  Time Date Type

  Datetime: Time date, format is Yyyy-mm-dd HH:ii:ss, returns from 1000 to 9999 with 0 value: 0000-00-00 00:00:00

Date: Dates, which is the date part in DateTime.

Time: Duration (segment), specified by Mo interval,-time to + time.

Timestamp: Timestamps are not really timestamps. Just Yyyy-mm-dd HH:ii:ss, which began in 1970, has exactly the same format as DateTime. As soon as the current record is updated, the field is automatically updated to the current time.

Year: Vintage, two forms, years (2) and yearly (4).

  

PHP for the implementation of the main object, PHP has a very powerful time and date processing functions, date, only a timestamp can be converted to any type of time, PHP-based, are used in the database Timestamp (integer) to store time.

  

R

I

MySQL basic note (vi)-data type one

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.