增加唯一性约束
alter table t_pat_patent ADD unique(no)
2.删除重复记录只保留一条
DELETE FROM t_pat_patent WHERE id IN ( SELECT id FROM ( SELECT max(id) AS id, count(no) AS count FROM t_pat_patent GROUP BY no HAVING count > 1 ORDER BY count DESC ) AS tab ) and proposalCode in ('20160118100704777','20160114101125115','20151119150703372','20160122081524664')
3.更新显示名
update t_sys_user ,viewnameinfo set t_sys_user.displayname = viewnameinfo.viewName where `t_sys_user`.staffId = viewnameinfo.staffid ; update t_sys_user user set user.displayname = (select viewName from viewnameinfo v where `user`.staffId = v.staffid) ; UPDATE t_sys_user USER SET USER .displayname = ( SELECT case when viewName is null then `user`.displayname else viewName end FROM viewnameinfo v WHERE `user`.staffId = v.staffid )
4.事务
start transaction; commit ;
5.锁表
LOCK TABLES `t_bpm_process_task` WRITE; UNLOCK TABLES;
6.mysql查询区分大小写 BINARY
select count(id) from t_per_staffinfo staffinfo where BINARY staffinfo.idCard = #{idCard}
7.release迁移sql
##需要提供目标库processdefineid 源库processdefineid ##定义目标库变量 ##查询sql为 目标库执行sql 结果集copy 到下发 select CONCAT("SET @processdefineid = '",a.id,"',@deploymentid = '",a.deploymentId,"',@formdefineid = '",b.formDefineId,"';") from t_bpm_process_define a left join t_bpm_node_set b on a.id=b.processDefineId where a.id= ? ##定义源库变量 源数据库结果集 select CONCAT("SET @SRCprocessdefineid = '",id,",@SRCdeployId = '",deploymentId,"';") from t_bpm_process_define where id= ? ##目标库结果集 ##源数据库结果集 ##同步经办人 SELECT CONCAT( "insert into t_bpm_user_assign VALUES('", id, "','" ,@deploymentid, "',", "'", activityName, "',", "'", ifnull(roleId, ''), "',", "'", ifnull(roleName, ''), "',", "'", ifnull(userId, ''), "',", "'", ifnull(username, ''), "',", "'", ifnull(isSigned, ''), "',", "'", ifnull(isForm, ''), "',", "'", ifnull(chooseRule, ''), "',", "'", ifnull(positionId, ''), "',", "'", ifnull(positionName, ''), "',", "'", ifnull(createTime, ''), "',", "'", ifnull(modifyTime, ''), "',", "'", ifnull(createUserCode, ''), "',", "'", ifnull(modifyUserCode, ''), "',", "'", ifnull(fieldName, ''), "');" ) AS INSERT_SQL FROM t_bpm_user_assign WHERE deployId IN ( SELECT deploymentid FROM t_bpm_process_define WHERE id = @SRCprocessdefineid ) UNION ##同步条件 SELECT CONCAT( "insert into t_bpm_decision VALUES('", id, "','" ,@deploymentid, "',", "'", ifnull(activityName, ''), "',", "'", ifnull(ruleExpression, ''), "');" ) AS INSERT_SQL FROM t_bpm_decision WHERE deployId IN ( SELECT deploymentid FROM t_bpm_process_define WHERE id = @SRCprocessdefineid ) UNION ## 同步表单权限 SELECT CONCAT( "insert into t_bpm_form_rights VALUES('", id, "',", "'" ,@formdefineid, "',", "'" ,@processdefineid, "',", "'", ifnull(activityName, ''), "',", "'", ifnull(permission, ''), "',", "'", ifnull(NAME, ''), "',", "'", ifnull(type, ''), "');" ) AS INSERT_SQL FROM t_bpm_form_rights WHERE processdefineid =@SRCprocessdefineid UNION ## 同步前后置任务 SELECT CONCAT( "insert into t_bpm_trigger VALUES('", id, "',", "'" ,@processdefineid, "',", "'" ,@deploymentid, "',", "'", ifnull(activityName, ''), "',", "'", ifnull(beforehandler, ''), "',", "'", ifnull(afterhandler, ''), "');" ) AS INSERT_SQL FROM t_bpm_trigger WHERE processdefineid =@SRCprocessdefineid AND deployId =@SRCdeployId ##将最后查询结果集在 目标数据库中执行即可
8.修改jpdl的语句
2.修改jpdl的语句 ######修改jbpm4_lob,修改请假表定义###### update jbpm4_lob set blob_value_='****' where deployment_=8610174; ######修改t_bpm_process_define,修改请假表定义###### update t_bpm_process_define set jpdlXml='****' where id='2c913f9e4906ec2001490c3a680f39f7';
9.修改个别单子的经办人逻辑(目前已为管理员提供前台操作入口)
update jbpm4_task set ASSIGNEE_ = 'dong02.yang' where ASSIGNEE_='yonghao.he' and DBID_=9685898; update t_bpm_process_execution set modifyUserCode='dong02.yang' where modifyUserCode='yonghao.he' and processInstanceId = '员工转正评定.8361018' ; update t_bpm_process_task set createUserCode='dong02.yang' where createUserCode='yonghao.he' and finishTime is null and taskId=9010882 ;
10.