Common data types for MySQL

Source: Internet
Author: User

Not much to say, directly on the dry goods!

common data types for MySQL

First, what is the data type?

Data types are data characteristics of columns, stored procedure parameters, expressions, and local variables, which determine the storage format of the data and represent different types of information.

Some of the data is to be stored as numbers, some of which are stored as integers, decimals, date types, etc...

Second, MySQL common data types

MySQL supports multiple types, roughly divided into four categories: numeric, float, date/time, and string (character) types .

 1. Numeric type

MySQL supports all standard SQL numeric data types.

  These numeric types include strict numeric data types (INTEGER, SMALLINT, Decimal, and numeric), as well as approximate numeric data types (FLOAT, real, and double PRECISION).

The keyword int is a synonym for integer, and the keyword Dec is a synonym for decimal.

As an extension of the SQL standard, MySQL also supports integer types tinyint, Mediumint, and bigint. The following table shows the storage and scope of each integer type that is required:

  2, floating-point type

For example, the wages we send are usually marked with decimals.

3. Date and Time type

The date and time types that represent time values are datetime, date, TIMESTAMP, hour, and year.

Each time type has a valid value range and a value of "0", and a value of "0" is used when specifying an illegal MySQL value that cannot be represented.

The timestamp type has a proprietary Automatic Update feature, which is described later.

  In production, date and time type, often use less, but with the number of types to replace the date type!

  4 String type

The string type refers to Char, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, enum, and set. This section describes how these types work and how they are used in queries.

Char and varchar types are similar, but they are saved and retrieved in different ways. They are also different in terms of their maximum length and whether trailing spaces are retained. No case conversions are made during the storage or retrieval process.

Binary and varbinary classes are similar to char and varchar, but they contain binary strings rather than binary strings. That is, they contain a byte string instead of a character string. This means that they do not have a character set, and sort and compare numeric values based on column-valued bytes.

There are 4 types of text: Tinytext, text, Mediumtext, and Longtext. These correspond to 4 types of blobs, with the same maximum length and storage requirements.

 

  enum is an enum type

  set is a collection type different from the enum type, which is a permutation combination. If there is ABC, it can choose a or B or C, also have the choice is AB,AC,BC, also can choose ABC.

Summarize

These data types can be used in data tables or stored procedures or in later functions, meaning that whenever a data type is used, it can be selected from the type of numeric, floating-point, date/time, and string (character) types we just talked about.

Common data types for MySQL

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.