查看mysql字符集

查看所有表的字符集

SELECT table_name, table_type, engine, version, table_collation FROM information_schema.tables WHERE table_schema = ‘test_db11‘ ORDER BY table_name DESC;

查看单张表字段的字符集

SHOW FULL COLUMNS FROM sw_test_table11;

使用效果截图

查看mysql字符集

转载:https://www.cnblogs.com/youjianjiangnan/p/9114791.html

修改数据库字符集

ALTER DATABASE db_name DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

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

ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

只是修改表的默认字符集
  
ALTER TABLE tbl_name DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

修改字段的字符集

ALTER TABLE tbl_name CHANGE title title VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

查看数据库编码

SHOW CREATE DATABASE db_name;

查看表编码

SHOW CREATE TABLE tbl_name;

查看字段编码

SHOW FULL COLUMNS FROM tbl_name;

相关推荐