MySQLl修改表、字段、库的字符集

修改数据库字符集:

ALTERDATABASE db_nameDEFAULTCHARACTERSET  character_name[COLLATE...];

 

把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集:

ALTERTABLE tbl_nameCONVERTTOCHARACTERSET character_name[COLLATE...]

如:ALTERTABLE logtestCONVERTTOCHARACTERSET utf8COLLATE utf8_general_ci;

 

只是修改表的默认字符集:

ALTERTABLE tbl_nameDEFAULTCHARACTERSET character_name[COLLATE...];

如:ALTERTABLE logtestDEFAULTCHARACTERSET utf8COLLATE utf8_general_ci;

 

修改字段的字符集:

ALTERTABLE tbl_nameCHANGE c_name c_nameCHARACTERSET character_name[COLLATE...];

如:ALTERTABLE logtestCHANGE title titleVARCHAR(100)CHARACTERSET utf8 COLLATE utf8_general_ci;

 

查看数据库编码:

SHOWCREATEDATABASE db_name;

 

查看表编码:

SHOWCREATETABLE tbl_name;

 

查看字段编码:

SHOWFULLCOLUMNSFROM tbl_name;

 

 

你可能感兴趣的:(MySQLl修改表、字段、库的字符集)