Higher priority for setting character sets when defining fields

Source: Internet
Author: User

| Articles | CREATE TABLE ' articles ' (' id ' int (one) not null auto_increment, ' content ' longtext not null, PRIMARY KEY (' id ')) ENGINE =innodb auto_increment=16 DEFAULT charset=latin1 |mysql> select * from articles;+----+---------+| ID | Content |+----+---------+| 11 | Ha | | 12 | Xi | | 13 | Ai | | 14 | Ho | |      15 |?? |+----+---------+5 rows in Set (0.01 sec) mysql> ALTER TABLE articles default character set UTF8; Query OK, 5 rows affected (0.38 sec) records:5 duplicates:0 warnings:0mysql> SELECT * from articles;+----+--------- +| ID | Content |+----+---------+| 11 | Ha | | 12 | Xi | | 13 | Ai | | 14 | Ho | |      15 |?? |+----+---------+5 rows in Set (0.01 sec) | Articles | CREATE TABLE ' articles ' (' id ' int (one) not null auto_increment, ' content ' Longtext CHARACTER SET latin1 not NULL, PRIMA RY KEY (' id ')) engine=innodb auto_increment=16 DEFAULT Charset=utf8 |mysql> insert into articles (Id,content) VALUES (1 6, ' modify character set '); Query OK, 1 Row affected, 1 warning (0.08 sec) mysql> Select * from articles;+----+---------+| ID | Content |+----+---------+| 11 | Ha | | 12 | Xi | | 13 | Ai | | 14 | Ho | |      15 |?? ||   ????? |+----+---------+6 rows in Set (0.00 sec) # But the problem is still, as if only deleted, re-import data will take effect! Understand when the table is built, the field definition is: ' content ' longtext CHARACTER SET latin1 not null,mysql> insert into articles (Id,content) VALUES (1, ' Forest '), (2, ' Chen '); Query OK, 2 rows affected, 2 warnings (0.10 sec) records:2 duplicates:0 warnings:2mysql> select * from articles;+-- --+---------+| ID |  Content |+----+---------+|       1 |?  ||       2 |? |+----+---------+2 rows in Set (0.00 sec)

mysql> drop table articles; Query OK, 0 rows affected (0.11 sec) mysql> CREATE TABLE ' articles ' (   ' id ' int (one) ' Not NULL auto_increment,   ' con Tent ' longtext not  NULL,   PRIMARY KEY (' id ')) engine=innodb auto_increment=15 DEFAULT Charset=utf8; Query OK, 0 rows affected (0.08 sec) mysql> insert into articles (Id,content) VALUES (1, ' Forest '), (2, ' Chen '); Query OK, 2 rows affected (0.08 sec) records:2  duplicates:0  warnings:0mysql> select * from articles;+----+--- ------+| ID | Content |+----+---------+|  1 | Forest      | |  2 | Chen      |+----+---------+2 rows in Set (0.00 sec)

Higher priority for setting character sets when defining fields

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.