MySql表、字段、库的字符集修改及查看方法_MySQL
程序员文章站
2022-04-19 10:17:57
...
修改数据库字符集:
把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集:
如:ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
如:ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
如:ALTER TABLE logtest CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;
查看表编码:
查看字段编码:
代码如下:
ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
把表默认的字符集和所有字符列(CHAR,VARCHAR,TEXT)改为新的字符集:
代码如下:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET character_name [COLLATE ...]
如:ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
只是修改表的默认字符集:
代码如下:
ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE...];
如:ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
修改字段的字符集:
代码如下:
ALTER TABLE tbl_name CHANGE c_name c_name CHARACTER SET character_name [COLLATE ...];
如:ALTER TABLE logtest CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;
查看数据库编码:
代码如下:
SHOW CREATE DATABASE db_name;
查看表编码:
代码如下:
SHOW CREATE TABLE tbl_name;
查看字段编码:
代码如下:
SHOW FULL COLUMNS FROM tbl_name;
上一篇: 使用PHPMyAdmin修复论坛数据库的图文方法_php实例
下一篇: 详解PHP字符串的组成方式
推荐阅读