Character-type data
Character data can be implemented with a fixed length or variable length string, which differs in that a fixed string of strings is filled with spaces to the right to ensure that the same number of bytes is used; variable-length strings do not need to be filled to the right, and all bytes are variable.
Char fixed length, byte length fixed, maximum length of 255 bytes, you can use char (20) This way to limit length, query speed, but not flexible
varchar, byte length varies with the amount of data, can store up to 65535 bytes, varchar (20) can be limited to length, query speed less than char, but the use of flexible
If you need to store text or documents, you need to use text type data, including four
Tinytext 255 bytes
Text 65535 bytes
Mediumtext 16777215 bytes
Longtext 4294967295 bytes
The above three types are compared by using the first 1024 bytes when sorting or comparing groups
Character
For Latin languages, such as English, where each letter requires only 1 bytes to store, and other languages, such as Chinese, contain a large number of characters, each character's storage requires multiple bytes, so this kind of character set is called the multiple character set
In MySQL, you can use the show Cahracter Set statement to view character sets
Copy Code code as follows:
Mysql> show CHARACTER SET;
+----------+-----------------------------+---------------------+--------+
| Charset | Description | Default Collation | MaxLen |
+----------+-----------------------------+---------------------+--------+
| Big5 | Big5 Traditional Chinese | Big5_chinese_ci | 2 |
| Dec8 | DEC West European | Dec8_swedish_ci | 1 |
| cp850 | DOS West European | Cp850_general_ci | 1 |
| HP8 | HP West European | Hp8_english_ci | 1 |
| koi8r | Koi8-r relcom Russian | Koi8r_general_ci | 1 |
| Latin1 | cp1252 West European | Latin1_swedish_ci | 1 |
| latin2 | ISO 8859-2 European | Latin2_general_ci | 1 |
| Swe7 | 7bit Swedish | Swe7_swedish_ci | 1 |
| ASCII | US ASCII | Ascii_general_ci | 1 |
| Ujis | EUC-JP Japanese | Ujis_japanese_ci | 3 |
| Sjis | Shift-jis Japanese | Sjis_japanese_ci | 2 |
| Hebrew | ISO 8859-8 Hebrew | Hebrew_general_ci | 1 |
| tis620 | TIS620 Thai | Tis620_thai_ci | 1 |
| Euckr | EUC-KR Korean | Euckr_korean_ci | 2 |
| koi8u | Koi8-u Ukrainian | Koi8u_general_ci | 1 |
| gb2312 | GB2312 Simplified Chinese | Gb2312_chinese_ci | 2 |
| Greek | ISO 8859-7 Greek | Greek_general_ci | 1 |
| cp1250 | Windows European | Cp1250_general_ci | 1 |
| GBK | GBK Simplified Chinese | Gbk_chinese_ci | 2 |
| Latin5 | ISO 8859-9 Turkish | Latin5_turkish_ci | 1 |
| Armscii8 | ARMSCII-8 Armenian | Armscii8_general_ci | 1 |
| UTF8 | UTF-8 Unicode | Utf8_general_ci | 3 |
| UCS2 | UCS-2 Unicode | Ucs2_general_ci | 2 |
| cp866 | DOS Russian | Cp866_general_ci | 1 |
| KEYBCS2 | DOS Kamenicky Czech-slovak | Keybcs2_general_ci | 1 |
| Macce | Mac European | Macce_general_ci | 1 |
| Macroman | Mac West European | Macroman_general_ci | 1 |
| cp852 | DOS European | Cp852_general_ci | 1 |
| latin7 | ISO 8859-13 Baltic | Latin7_general_ci | 1 |
| UTF8MB4 | UTF-8 Unicode | Utf8mb4_general_ci | 4 |
| cp1251 | Windows Cyrillic | Cp1251_general_ci | 1 |
| UTF16 | UTF-16 Unicode | Utf16_general_ci | 4 |
| cp1256 | Windows Arabic | Cp1256_general_ci | 1 |
| cp1257 | Windows Baltic | Cp1257_general_ci | 1 |
| Utf32 | UTF-32 Unicode | Utf32_general_ci | 4 |
| binary | Binary Pseudo CharSet | binary | 1 |
| Geostd8 | GEOSTD8 Georgian | Geostd8_general_ci | 1 |
| cp932 | Sjis for Windows Japanese | Cp932_japanese_ci | 2 |
| Eucjpms | Ujis for Windows Japanese | Eucjpms_japanese_ci | 3 |
+----------+-----------------------------+---------------------+--------+
Rows in Set (0.00 sec)
Where the MaxLen column is greater than 1, it represents this row as a multiple character set, such as gb2312, which requires a maximum of 2 bytes for storing a Chinese character, and utf8 up to 3
Numeric type data
Integer type data
Floating-point data
Numeric data can be defined as unsigned, which can change the range of integers, and can be limited to negative numbers for floating-point numbers.
Time data