MySQL innodb table UTF8 GBK occupy the same space, destroy three views

Source: Internet
Author: User

Yesterday, because of the character set conversion related errors, today want to verify the next UTF8 and gbk the gap between the respective space. This test, the absolute destruction of the three views, whether Chinese or Chinese + English, GBK and UTF8 occupy the actual physical size is exactly the same, is not theoretically described as "UTF-8 to Chinese 3 bytes, the English use 1 bytes, GBK to both English and Chinese use 2 bytes", as follows:

Empty table:

GBK as follows:

CREATE TABLE ' TEST_CHAR_GBK ' (
' gbk_str ' varchar (+) DEFAULT NULL
) Engine=innodb DEFAULT CHARSET=GBK;

INSERT into TEST_CHAR_GBK VALUES (' ffhpf2fhfh2hfh32h82h832h328fhf28fh3283h83h8h82h382 ');

INSERT INTO TEST_CHAR_GBK select * from TEST_CHAR_GBK

Total 65536 rows affected

UTF8:

CREATE TABLE ' Test_char_utf8 ' (
' utf8_str ' varchar (+) DEFAULT NULL
) Engine=innodb DEFAULT Charset=utf8;

INSERT into Test_char_utf8 VALUES (' ffhpf2fhfh2hfh32h82h832h328fhf28fh3283h83h8h82h382 ');

INSERT INTO Test_char_utf8 select * from Test_char_utf8

Total 65536 rows affected

============= again the combination of English, the actual majority is also a combination of =============

TRUNCATE TABLE Test_char_utf8;

INSERT into Test_char_utf8 VALUES (' ffhpf2fhfh2hfh32h82h832h328fhf28fh3283h83h8h82h382 ');
INSERT into Test_char_utf8 VALUES (' China China China, China, China ');

INSERT INTO Test_char_utf8 select * from Test_char_utf8

Total 65536 rows affected

TRUNCATE TABLE TEST_CHAR_GBK;

INSERT into TEST_CHAR_GBK VALUES (' ffhpf2fhfh2hfh32h82h832h328fhf28fh3283h83h8h82h382 ');
INSERT into TEST_CHAR_GBK VALUES (' China China China, China, China ');

INSERT INTO TEST_CHAR_GBK select * from TEST_CHAR_GBK

Total 65536 rows affected

I'll go..... Not so fun ....

MySQL innodb table UTF8 GBK occupy the same space, destroy three views

Related Article

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.