• mysql修改字符集


    MySQL中默认字符集的设置有四级:服务器级,数据库级,表级 。最终是字段级 的字符集设置。注意前三种均为默认设置,并不代码你的字段最终会使用这个字符集设置。所以我们建议要用show create table table ; 或show full fields from tableName; 来检查当前表中字段的字符集设置。

     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;

    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;
  • 相关阅读:
    安卓开发_浅谈Android动画(三)
    安卓开发_浅谈Android动画(二)
    安卓开发_浅谈Android动画(一)
    Go语言获取系统性能数据gopsutil库
    Go语言标准库之log
    选项模式
    Go语言标准库之template
    Go语言基础之切片
    Go语言基础之反射
    Go语言基础之运算符
  • 原文地址:https://www.cnblogs.com/zongyl/p/10131062.html
Copyright © 2020-2023  润新知