下面是一个mysql的视图,在表明前面自动带有数据库名称 misdb
select `b`.`id` AS `id`,`c`.`sId` AS `billType`,`a`.`billCode` AS `billCode`,if(isnull(`b`.`targetUnitId`),`b`.`clientId`,`b`.`targetUnitId`) AS `clientId`,`b`.`pairs` AS `pairs`,`b`.`meter` AS `meter`,`b`.`kilo` AS `kilo`,if(isnull(`b`.`targetUnitId`),`f`.`name`,`g`.`name`) AS `company`,`b`.`greyfabricId` AS `greyfabricId`,`h`.`name` AS `greyfabric`,`i`.`name` AS `cutter`,`b`.`title` AS `title`,`b`.`cutterId` AS `cutterId`,cast((ifnull(`b`.`kilo`,0) - ifnull(`d`.`kilo`,0)) as decimal(30,2)) AS `remain_kilo`,cast((ifnull(`b`.`meter`,0) - ifnull(`d`.`meter`,0)) as decimal(30,2)) AS `remain_meter`,cast((ifnull(`b`.`pairs`,0) - ifnull(`d`.`pairs`,0)) as decimal(30,2)) AS `remain_pairs`,cast((ifnull(`b`.`kilo`,0) - ifnull(`e`.`kilo`,0)) as decimal(30,2)) AS `audit_kilo`,cast((ifnull(`b`.`meter`,0) - ifnull(`e`.`meter`,0)) as decimal(30,2)) AS `audit_meter`,cast((ifnull(`b`.`pairs`,0) - ifnull(`e`.`pairs`,0)) as decimal(30,2)) AS `audit_pairs`,`b`.`valuateId` AS `valuateId`,`b`.`price` AS `price`,`b`.`total` AS `total`,`b`.`number` AS `number`,`b`.`cage` AS `cage`,`b`.`product_name` AS `product_name`,`b`.`pairNO` AS `pairNO`,`b`.`tip` AS `tip`,`a`.`date` AS `date`,`b`.`widthgramme` AS `widthgramme`,`b`.`ordercode` AS `ordercode` from ((((((((`misdb`.`bpbillmain` `a` left join `misdb`.`bpbilldetail` `b` on(((`a`.`billCode` = `b`.`billCode`) and (`b`.`status` = 1)))) left join `misdb`.`billtype` `c` on((`b`.`billtypeId` = `c`.`id`))) left join (select `a`.`vatNO` AS `vatNO`,`a`.`date` AS `date`,`b`.`id` AS `id`,`b`.`pId` AS `pId`,`b`.`vId` AS `vId`,sum(ifnull(`b`.`pairs`,0)) AS `pairs`,sum(ifnull(`b`.`kilo`,0)) AS `kilo`,sum(ifnull(`b`.`meter`,0)) AS `meter` from ((`misdb`.`bpbillmain` `a` left join `misdb`.`bpbilldetail` `b` on(((`a`.`billCode` = `b`.`billCode`) and (`b`.`status` = 1)))) left join `misdb`.`billtype` `c` on((`b`.`billtypeId` = `c`.`id`))) where (((`c`.`accessMode` = -(1)) or ((`c`.`accessMode` = 0) and (length(ifnull(`b`.`targetUnitId`,'')) > 0))) and (`a`.`status` = 1) and (`b`.`isOut` in (1,2))) group by `b`.`pId`) `d` on((`d`.`pId` = `b`.`id`))) left join (select sum(`a`.`kilo`) AS `kilo`,sum(`a`.`pairs`) AS `pairs`,sum(`a`.`meter`) AS `meter`,`a`.`pId` AS `pId`,`a`.`id` AS `id` from ((select sum(if(isnull(`e`.`pId`),`b`.`kilo`,`e`.`kilo`)) AS `kilo`,sum(if(isnull(`e`.`pId`),`b`.`pairs`,`e`.`pairs`)) AS `pairs`,sum(if(isnull(`e`.`pId`),`b`.`meter`,`e`.`meter`)) AS `meter`,`b`.`pId` AS `pId`,`b`.`id` AS `id`,`d`.`vatNum` AS `vatNum`,`d`.`id` AS `planId` from ((((`misdb`.`bpbillmain` `a` left join `misdb`.`bpbilldetail` `b` on(((`a`.`billCode` = `b`.`billCode`) and (`b`.`status` = 1)))) left join `misdb`.`billtype` `c` on((`b`.`billtypeId` = `c`.`id`))) left join `misdb`.`plan` `d` on((`a`.`vatNO` = `d`.`vatNum`))) left join (select sum(ifnull(`a`.`kilo`,0)) AS `kilo`,sum(ifnull(`a`.`pairs`,0)) AS `pairs`,sum(ifnull(`a`.`meter`,0)) AS `meter`,`a`.`pId` AS `pId`,`a`.`vId` AS `vId` from ((`misdb`.`bpbilldetail` `a` left join `misdb`.`billtype` `b` on((`a`.`billtypeId` = `b`.`id`))) left join `misdb`.`bpbilldetail` `c` on((`a`.`pId` = `c`.`id`))) where ((`a`.`status` = 1) and (`a`.`vId` is not null)) group by `a`.`vId`,`a`.`pId`) `e` on(((`d`.`id` = `e`.`vId`) and (`e`.`pId` = `b`.`pId`)))) where ((`a`.`status` = 1) and (`b`.`isOut` = 0)) group by `b`.`pId`) union all (select sum(`a`.`kilo`) AS `kilo`,sum(`a`.`pairs`) AS `pairs`,sum(`a`.`meter`) AS `meter`,`a`.`pId` AS `pId`,`a`.`id` AS `id`,NULL AS `vatNum`,NULL AS `planId` from (`misdb`.`bpbilldetail` `a` left join `misdb`.`billtype` `b` on((`a`.`billtypeId` = `b`.`id`))) where (((`b`.`accessMode` = -(1)) or ((`b`.`accessMode` = 0) and (length(ifnull(`a`.`targetUnitId`,'')) > 0))) and (`b`.`id` <> 14) and (`a`.`status` = 1) and isnull(`a`.`vId`) and (`a`.`isOut` in (1,2))) group by `a`.`pId`)) `a` group by `a`.`pId`) `e` on((`e`.`pId` = `b`.`id`))) left join `misdb`.`contactcompany` `f` on((`f`.`sId` = `b`.`clientId`))) left join `misdb`.`contactcompany` `g` on((`g`.`sId` = `b`.`targetUnitId`))) left join `misdb`.`greyfabric` `h` on((`b`.`greyfabricId` = `h`.`id`))) left join `misdb`.`contactcompany` `i` on((`i`.`sId` = `b`.`cutterId`))) where ((`a`.`status` = 1) and ((`c`.`accessMode` = 1) or ((`c`.`accessMode` = 0) and (length(ifnull(`b`.`targetUnitId`,'')) > 0)))) order by `b`.`id` desc
当我把备份的数据恢复到 misdb01 时由于视图内自带的数据库名称还是 misdb 导致系统内看到的数据是数据库 misdb 中的数据,而不是 misdb01 的数据。我通过 navicat 恢复数据库时如何能将视图中自带的这个数据库名称去掉?