首页 > 其他分享 >Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT)

Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT)

时间:2023-09-08 23:04:35浏览次数:43  
标签:test1 ci name utf8mb4 ai 0900 IMPLICIT

一、概述

今天同事突然询问报错
Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='

分析:
应该是连表查询,两张表的的匹配列编码格式不一致引起的

二、问题复现

1、创建两张小表
create table test1 (
name varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
);
create table test2 (
name varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci
);

2、插入数据
insert into test1 values ('guanyu'),('zhangfei'),('zhaoyun');
insert into test2 values ('zhangliao'),('dianwei'),('guanyu');

3、复现报错情况
情况一
select t1.name from test1 t1,test2 t2 where t1.name=t2.name;

情况二
select name,(select name from test2 where name = (select name from test1 where name='guanyu')) name2 from test1;

由于两张表对应的name列编码格式不一样,直接报错
Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='

三、问题修复

1、查看数据库的默认编码格式
show variables where Variable_name like 'collation%';
此处只是建议,并不一定非要按照默认编码格式

Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT)_默认编码

2、重置表的编码格式
alter table test1 default character set utf8mb4 collate=utf8mb4_0900_ai_ci;

3、修改表中字段编码格式
ALTER TABLE test1 convert to CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

标签:test1,ci,name,utf8mb4,ai,0900,IMPLICIT
From: https://blog.51cto.com/u_13236892/7413627

相关文章

  • 打包发布版时报错 Error: The apk for your currently selected variant cannot be si
    当直接运行release版本时,报错Error:Theapkforyourcurrentlyselectedvariantcannotbesigned.Pleasespecifyasigningconfigurationforthisvariant(release).解决报错:要在配置里添加签名android{signingConfigs{debug{storeFil......
  • Annotation processors must be explicitly declared now
    AndroidStudio升级到最新版3.0Canary8后,当使用到注解时,报了如下错误:Error:Executionfailedfortask':app:javaPreCompileDebug'.>Annotationprocessorsmustbeexplicitlydeclarednow.Thefollowingdependenciesonthecompileclasspatharefoundtocontain......
  • P5051 [COCI2017-2018#7] Timo
    题目传送门思路由于题目给出的顺序是——$1{th}\to2\to3{th}\to\dots\to(n-1)\ton^{th}$$\to(n-1){th}\to(n-2)\to\dots\to2{th}\to1\to2^{th}$因为我们每走一回在开头和结尾只走了一次,而其他位数则走了两次,这样的话我们再分组的时候就可以不按照$1\to\dots\ton$来执行......
  • dependencies
    在Maven中,dependencies是用于定义项目的依赖关系的部分。dependencies元素中可以包含多个dependency元素,每个元素都包含了一个特定依赖的详细信息,如groupId、artifactId、version等。这些依赖关系将会被解析并添加到你的项目中,从而使得在项目中使用依赖的库的功能。这些依赖项会......
  • 无涯教程-JavaScript - ERF.PRECISE函数
    描述ERF.PRECISE函数返回错误函数。错误函数由公式给出-$$Erf(x)=\frac{2}{\sqrt{\pi}}\inte^{-t^2}dt$$ERF.PRECISE函数将积分的上限或下限设置为0(取决于用户提供的限制是正数还是负数)来计算此函数。如果要自己选择上限和下限,则应考虑使用ERF功能。语法ERF.......
  • 安全认证 | CISP考试资格及报考条件
    在参加CISP考试之前我们准备好相关的工作对于拿证是有很大的帮助的。那么CISP考试资格及报考条件是什么?下面我们就来了解一下吧。01CISP考试资格及报考条件★报考条件CISP考试条件详情:满足CISP教育和工作经验要求注册资格(1)教育和工作经验要求:硕士以上学历,有一年以上工作经验;或......
  • [论文阅读] Explicit Boundary Guided Semi-Push-Pull Contras
    ExplicitBoundaryGuidedSemi-Push-PullContrastiveLearningforSupervisedAnomalyDetectionIntroduction只关注正常样本可能会限制AD模型的可判别性。如图1(a)所示,在没有异常情况的情况下,决策边界通常是隐式的,没有足够的判别性。在无监督异常检测中,由于缺乏对异常的了解......
  • a different object with the same identifier value was already associated with th
    数据库更新记录报错:adifferentobjectwiththesameidentifiervaluewasalreadyassociatedwiththesession:[com.miracle.dm.sysmgr.user.model.OrgUserProInfo#4028800b269cc2f301269cc959960007];nestedexceptionisorg.hibernate.NonUniqueObjectException:adiffe......
  • [SpringSecurity5.6.2源码分析三]:SpringWebMvcImportSelector
    1、SpringWebMvcImportSelector• SpringSecurity支持在SpringMVC进行参数解析的时候填充参数,支持以下的对象• 通过@AuthenticationPrincipal,获取UserDetails• 通过@CurrentSecurityContext,获取SecurityContext• 通过参数类型为CsrfToken获取CsrfToken• 究其原因是因为Spr......
  • Android官方资料--Reducing OTA Size
    ReducingOTASizeINTHISDOCUMENTThebuilddifftoolChangestoreduceOTAsizeFileOrderBuildDirectoryTimestampsVersionStringsConsistentbuildtoolsAcommonproblemwithAndroidover-the-airupdates(OTAs)isthattheycontainchangedfilesthatdo......