Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Three main character types supported by Mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the three main character types supported by Mysql. I hope I can add and update some knowledge to you. If you have any other questions you need to know, you can continue to follow my updated article in the industry information.

MySQL supports many types, which can be roughly divided into three types: numeric, date / time, and string (character) types.

Numerical type

MySQL supports all standard SQL numeric data types.

These types include strict numeric data types (INTEGER, SMALLINT, DECIMAL, and NUMERIC) and approximate numeric data types (FLOAT, REAL, and DOUBLE PRECISION).

The keyword INT is synonymous with INTEGER, and the keyword DEC is synonymous with DECIMAL.

The BIT data type holds bit field values and supports MyISAM, MEMORY, InnoDB, and BDB tables.

As an extension of the SQL standard, MySQL also supports integer types TINYINT, MEDIUMINT, and BIGINT. The following table shows the storage and range of each integer type required.

Type size range (signed) range (unsigned) usage TINYINT1 byte (- 128127) (0255) small integer value SMALLINT2 byte (- 32 768 minus 32 767) (0meme 65 535) large integer value MEDIUMINT3 byte (- 8 388 608) (0mei 16 777 215) large integer value INT or INTEGER4 byte (- 2 147 483 648 4147 483 647) (0min 4 294 967 295) large integer value BIGINT8 byte (- 9 233 372 036 854 775 808) 9 223 372 036 854 775 807) (0Magna 18 446 744 073 709 551 551 615) maximum integer FLOAT4 bytes (- 3.402 823 466 Elaine 38 FLOAT4 bytes), 0, (1.175 494,351 Emai 38 3.402 823 466 351 Elux 38) 0, (1.175 494,351 E38 Ensemble 3.402 823 466 Ecards 38) single precision

Floating-point numeric DOUBLE8 bytes (- 1.797 693 134 862 315 7 Ecolors 308), 0, (2.225 073 858 507 201 4 Elym 308), 0, (2.225 073 858 507 201 4 Elyle 308) 0, (2.225 073 858 507 201 4 Ecolors 308 1.797 693 134 862 315 7)

Floating-point values DECIMAL to DECIMAL (M > D), if M > D, if M > D, otherwise, it depends on the decimal values of M and D, date and time type.

The date and time types that represent time values are DATETIME, DATE, TIMESTAMP, TIME, and YEAR.

Each time type has a range of valid values and a "zero" value, which is used when specifying values that cannot be represented by illegal MySQL.

The TIMESTAMP type has a proprietary automatic update feature, which will be described later.

Type size

(byte) range format use DATE31000-01-01 DATE31000 9999-12-31YYYY-MM-DD date value TIME3'-838:59:59'/'838:59:59'HH:MM:SS time value or duration YEAR11901/2155YYYY year value DATETIME81000-01-01 00 23:59:59YYYY-MM-DD HH:MM:SS mixed date and time value TIMESTAMP41970-01-01 00 DATE31000 mixed date and time value YYYYMMDD HHMMSS mixed date and time value sometime in 2037 Timestamp string type

String types refer to CHAR, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, ENUM and SET. This section describes how these types work and how to use them in queries.

Type size use CHAR0-255Byte fixed length string VARCHAR0-65535 byte variable length string TINYBLOB0-255Bytes binary string TINYTEXT0-255byte short text string BLOB0-65535 bytes long text data TEXT0-65535 bytes long text data MEDIUMBLOB0-1677215 bytes binary medium length text data MEDIUMTEXT0-1677215 bytes medium length text data LONGBLOB0-4 294 967 295 byte maximum text data LONGTEXT0-4 294 967 295 byte maximum text data in binary form

CHAR and VARCHAR types are similar, but they are saved and retrieved differently. They are also different in terms of maximum length and whether trailing spaces are retained. No case conversion occurs during storage or retrieval.

The BINARY and VARBINARY classes are similar to CHAR and VARCHAR, except that they contain binary strings rather than non-binary strings. That is, they contain byte strings instead of character strings. This means that they do not have a character set, and sort and compare numeric values based on column value bytes.

BLOB is a large binary object that can hold a variable amount of data. There are four types of BLOB: TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. They just differ in the maximum length of the allowable value.

There are four types of TEXT: TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to four BLOB types with the same maximum length and storage requirements.

After reading the above about the three main character types supported by Mysql, I hope it can bring some help to everyone in practical application. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report