您的位置:首页 > 博客中心 > 数据库 >

mysqldump对于DB进行逻辑备份的时候,是否会备份视图呢?

时间:2022-03-15 07:37

需求描述:

  今天在mysql备份的书的内容,提到了mysqldump在备份数据库的时候,不会备份视图

  所以,就做了个实验测试下,发现,是能够备份视图的,在此记录下.

环境描述:

  Mysql版本:5.5.57-log

操作过程:

1.对某个DB进行备份,库中包含视图v_test01

[mysql@redhat6 mysql_backup]$ mysqldump -uroot -p --single-transaction --master-data --databases top_server > TopServerDB.sql
Enter password: 

2.查看备份出来的SQL文件是否包含view相关信息

[mysql@redhat6 mysql_backup]$ grep "v_test01" TopServerDB.sql 
-- Temporary table structure for view `v_test01`
DROP TABLE IF EXISTS `v_test01`;
/*!50001 DROP VIEW IF EXISTS `v_test01`*/;
/*!50001 CREATE TABLE `v_test01` (
-- Final view structure for view `v_test01`
/*!50001 DROP TABLE IF EXISTS `v_test01`*/;
/*!50001 DROP VIEW IF EXISTS `v_test01`*/;
/*!50001 VIEW `v_test01` AS select `goods_share_order`.`id` AS `id`,`goods_share_order`.`share_num` AS `share_num`,`goods_share_order`.`contack_user` AS `contack_user`,`goods_share_order`.`contact_tel` AS `contact_tel`,`goods_share_order`.`share_date` AS `share_date`,`goods_share_order`.`share_deptid` AS `share_deptid`,`goods_share_order`.`goods_desc` AS `goods_desc`,`goods_share_order`.`goods_memo` AS `goods_memo`,`goods_share_order`.`creat_time` AS `creat_time`,`goods_share_order`.`update_time` AS `update_time`,`goods_share_order`.`operate_user` AS `operate_user`,`goods_share_order`.`refuse_num` AS `refuse_num`,`goods_share_order`.`total_num` AS `total_num`,`goods_share_order`.`dept_id` AS `dept_id`,`goods_share_order`.`share_status` AS `share_status`,`goods_share_order`.`user_id` AS `user_id`,`goods_share_order`.`remark` AS `remark` from `goods_share_order` */;

备注:说明备份出来的包括视图的信息,与书上说的内容不符合,可能是版本的区别.

3.将DB进行还原,在navicat中查看是否有视图

技术分享图片

备注:视图已经被还原回来了.说明这个mysql版本是能够备份视图的.

 

文档创建时间:2018年4月17日17:14:25

热门排行

今日推荐

热门手游