Read about mysql varchar length performance, The latest news, videos, and discussion topics about mysql varchar length performance from alibabacloud.com
This article describes in detail the performance and space occupied by varchar (n) and nvarchar (n) in SQL. For more information, see.
This article describes in detail the performance and space occupied by varchar (n) and nvarchar (n) in SQL. For more information, see.
How to explain n in
-sensitive, and the text value is case insensitive. In other words, a text is a case-insensitive blob.4. Summarize the difference between Char,varchar and textThe length of the difference, Char range is 0~255,varchar the longest is 64k, but note here 64k is the length of the entire row, to consider the other column, an
length of the difference, Char range is 0~255,varchar the longest is 64k, but note here 64k is the length of the entire row, to consider the other column, and if there is not NULL when it will occupy a bit, for different character sets, effective length is not the same, such as UTF8, up to 21845, but also to remove th
business logic is only for the char type design, so the database software also retains the char type.
2, the char type is fixed long, some database can not store the field length information in each record, this can save partial space, also can make some memory alignment to improve performance, but personally think this brings the performance improvement very s
does not, text can only store plain text files. The 4 text types Tinytext, text, Mediumtext, and Longtext correspond to 4 blob types and have the same maximum length and storage requirements. The only difference between blob and text types is that the sorting and comparison of BLOB values is case-sensitive, and the text value is case insensitive. In other words, a text is a case-insensitive blob.4. Summarize Char,
example, CHAR (30) can hold up to 30 characters. (Before MySQL 4.1, the length is interpreted as number of bytes .)
Let's take a look at similar descriptions of other versions:
The code is as follows:
The CHAR and VARCHAR types are declared with a length that indicates the maximum number of characters you want to st
In a database, character-type data is the most, and can account for more than 80% of the entire database. It is very important to improve the performance of database to deal with character data correctly. In character data, the most used is char and varchar two kinds. The front is fixed length, and the following is a variable
In a database, the majority type of data accounts for more than 80% of the total database. Therefore, correct processing of structured data can greatly improve database performance. In character data, Char and Varchar are the most common types. The front is a fixed length, while the back is a variable length. Now we ne
maximum-length character in the character set
BINARY (M)
m bytes, 0 m
VARCHAR (m), VARBINARY (m)
l + 1 bytes If column values require 0–255 bytes, l + 2 bytes If values may require more than 255 bytes
Tinyblob, tinytext
l + 1 bytes, where L 8
BLOB, TEXT
l + 2 bytes, where L
Mediumblob, mediumtext
l + 3 b
varchar type on the update link is much larger than the char type, so char is suitable for applications where fields are frequently updated . (2) varchar saves disk space (3) When large data volume extraction, varchar disk IO consumption is lower, which means that the performance of
Recently a few students asked me varchar and text have what do not, this problem, previously said really did not much collation, before the text in the design is as far as possible to the other table, to keep the main table as small as possible, so that the InnoDB BP cache more data.
Today, the system of opportunity to clean up, mainly from the storage, the maximum value, the default value of several aspects of comparison.
BTW: from the ISO sql:2003
Label:varchar and char are two of the most important string types. Unfortunately, it is difficult to explain precisely how these values are stored on disk and in memory because of the specific implementation of this storage engine. The following description assumes that the storage engine used is InnoDB or MyISAM. If you are not using either of these storage engines, refer to the documentation for the storage engine you are using.Let's look at how varchar
In mysql, the usage of char, varchar, and nvarchar data types is different.
In mysql, the usage of char, varchar, and nvarchar data types is different.
Note:1. char:A fixed length of non-Unicode characters. The maximum length i
We know the difference between char (m) and varchar (m) is that VARCHAR (m) is a variable-length string, and char (M) is a fixed-length string. For the time being, let's take a look at What is meant by M in CHAR (m) and VARCHAR (m), without regard to the problem of
applications, users can do this based on their own data types.
Note that the value of the last row in the table above applies only when the strict mode is not used. if MySQL runs in the strict mode, the value exceeding the column length is not saved and an error occurs.
The values retrieved from the CHAR (4) and VARCHAR (4) columns are not always the same, becau
The difference between char and varchar
char (13) length fixed, such as ' www.jb51.net ' storage requires space 12 characters
varchar (13) variable length as ' www.jb51.net ' requires storage space of 13 characters,
From the above you can see that the char length is fixed
storage space.In order to improve efficiency, it doesn't make sense for Vchar to transfer braces.
Rules used in MySQL to determine whether to convert to a column type
1, in a data table, if the length of each data column is fixed, then the length of each data row will also be fixed.2, as long as the data table has a variable
1. Logic meaning of varchar (N)From MySQL4.1, N in varchar (N) indicates the maximum number of characters (characters) that can be stored in this field, not the number of bytes.Whether it is a Chinese character or a number, or a Chinese character, it is regarded as a character. Before 4.1, N indicates the maximum number of bytes stored (bytes ).2. How long can varchar
encoding only supported 1-3 bytes, only support the BMP part of the Unicode coding area, BMP from where to?Poke here basically is 0000 ~ FFFF this area.Starting with MySQL 5.5, 4 byte UTF encoded UTF8MB4 can be supported, and a character can have a maximum of 4 bytes, so more character sets can be supported.utf8mb4 is a superset of utf8TF8MB4 is compatible with UTF8 and can represent more characters than UTF8.As for when to use, to see what you do th
MySQL Char,varchar,text,blob is a few links but there are a lot of different types of fields, which is the basis of MySQL, but the foundation did not learn, bad to fill.Let's summarize briefly:Char: fixed length , maximum 255 charactersVARCHAR: variable length , maximum 65,5
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.