dongpuchao1680 2015-09-20 10:27
浏览 60
已采纳

如何用旧数据填充新的和修改过的MySQL数据库

I have modified my PHP app together with MySQL table structure and now I want to update my app, But How can I populate the new modified tables with the old date.

Example: I had a table accounts with these columns: id, name, address and now my new table contains the old columns but has one editional so what is the best way to populate my new table with old data?

  • 写回答

1条回答 默认 最新

  • dongyong1400 2015-09-20 10:45
    关注

    If you are using phpMyAdmin. Click on the old database if you want to use the data in the whole database or choose the table with the data you would like to transfer.

    Click on Export. Leave format as SQL and click go.

    An SQL file should download to your desktop.

    If you have already created the new tables, open the downloaded sql file and edit out all the information except anything that starts with INSERT INTO TABLE . You will observe that all the insert statements have the table names listed directly after them. So in your case it would look like:

     INSERT INTO `accounts` (`id`, `name`, `address`) VALUES (1, 'John Doe', '44 St. NW'),
    

    This means that your data would be inserted directly into those columns. Id=1, name= John Doe, and Address = 44 St. NW. The fourth column you added will remain empty.

    Finally, click on the database that contains your new table. Click on import (again assuming you are using phpMyAdmin). If all your table names are exactly the same, it should run without error and import all your old data to your new table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟