MySQL备份之根据表备份概述

数据库 MySQL
此文章主要向大家讲述的是MySQL备份之根据表备份以及MySQL备份之根据表备份的实际应用,下面就是文章的具体内容描述。

以下的文章主要向大家介绍的是MySQL备份之根据表备份,本文主要是以实际应用代码的方式来引出MySQL备份之根据表备份,下面就是文章的主要内容描述,希望会给你带来一些帮助在此方面。

  1. <?php 
  2. function datatosql($table)   
  3. {   
  4. global $db;   
  5. $tabledump = "DROP TABLE IF EXISTS $table;\n";   
  6. $createtable = $db->query("SHOW CREATE TABLE $table");   
  7. $create = $db->fetch_array($createtable);   
  8. $tabledump .= $create[1].";\n\n";   
  9. $rows = $db->query("SELECT * FROM $table");   
  10. $numfields = $db->num_fields($rows);   
  11. $numrows = $db->num_rows($rows);   
  12. while ($row = $db->fetch_array($rows)){   
  13. $comma = "";   
  14. $tabledump ."INSERT INTO $table VALUES(";   
  15. for($i = 0; $i < $numfields; $i++)   
  16. {   
  17. $tabledump .= $comma."'".MySQL_escape_string($row[$i])."'";   
  18. $comma = ",";   
  19. }   
  20. $tabledump .");\n";   
  21. }   
  22. $tabledump ."\n";   
  23. return $tabledump;   
  24. }  

以上的相关内容就是对MySQL备份之-根据表备份的介绍,望你能有所收获。

MySQL备份

以上的相关内容就是对MySQL备份之-根据表备份的介绍,望你能有所收获。

【编辑推荐】

  1. 实现MySQL 用户密码的设置步骤
  2. MySQL数据库安全设置的操作流程
  3. 使用MySQL管理心得讲述
  4. MySQL基本操作,新手入门宝典
  5. jsp MySQL 中的中文问题的产生与解决
责任编辑:佚名 来源: cnblogs
相关推荐

2010-10-15 11:39:54

Mysql表备份

2010-04-26 18:11:55

Unix文件系统

2010-11-23 16:21:07

MySQL大表备份

2019-12-13 10:31:45

数据库SQLMySQL

2010-05-31 09:58:48

MySQL备份

2017-07-10 16:00:47

Mysql数据备份数据还原

2017-07-07 10:40:24

MySQL备份原理

2011-04-07 17:21:38

mysqlhotcop备份MySQL

2010-05-31 15:34:34

MySQL数据库

2022-05-30 11:21:25

数据库MySQL工具

2011-10-17 16:11:00

MySQL

2011-03-28 16:12:55

mysql自动远程备份

2011-03-23 17:21:42

2015-03-18 13:39:35

MySQLBackup数据库备份种类

2011-05-24 10:11:30

MySQLMongoDB

2019-01-24 09:39:51

2015-07-16 14:33:36

TB级mysqlxtrabackup备份迁移

2010-10-29 09:36:49

完全备份增量备份差异备份

2011-07-26 10:15:14

数据备份服务器虚拟化

2019-07-16 11:55:27

混合云互联网云备份
点赞
收藏

51CTO技术栈公众号