下载了两个数据库备份文件,他们的结构是完全相同的,现在需要将其合并成一个数据库。
不知这里有学生物或搞生物信息的没有,只是ipi数据库的下载文件。
他里面有文档说可以用drop来编辑备份数据库。IPI MySQL Dumps are species specific in the same way as other IPI distributed files, and they are intended to be loaded in different databases as explained in this page. However, the schema and table definitions have been changed (since July 2006 Release) to allow the load of different species into a single MySQL database. Here are some guide lines on how to achieve this:   1. load the first species dump normally without editing it, e.g.      mysql -h host_name -u username -ppassword IPI < ipi.HUMAN.mysql
   2. then edit the following species dumps you want to load into the same MySQL database to remove lines starting with "DROP TABLE IF EXISTS", e.g.      DROP TABLE IF EXISTS `organism`;
      DROP TABLE IF EXISTS `release`;
      DROP TABLE IF EXISTS `data_source`;
      etc...
   3. finally, load the edited files using MySQL '--force' and '--disable-named-commands' options, e.g.      mysql -h host_name -u username -ppassword --force --disable-named-commands IPI <
      ipi.MOUSE.mysql.edited
      mysql -h host_name -u username -ppassword --force --disable-named-commands IPI <
      ipi.RAT.mysql.edited
      etc...
On linux you can merge steps 2 and 3 in a single command line, e.g.sed s/DROP TABLE IF EXISTS.*// ipi.MOUSE.mysql | mysql -h host_name -u username -ppassword --force
--disable-named-commands IPI
sed s/DROP TABLE IF EXISTS.*// ipi.RAT.mysql | mysql -h host_name -u username -ppassword --force
--disable-named-commands IPI
etc...

解决方案 »

  1.   

    谢谢,
    表结构已经明白
    1.请问文档提到的drop TABLE的时候是不是要先将第二个表导入到数据库才能操作?
    2.你提到的数据转换时什么意思?
      

  2.   

    不知道,我根本没看那段英文。因为和合并没什么关系。假设两个库中都中auto_increment字段,则会出现两个 1,则需要进行转换。
      

  3.   

    没有auto_increment字段,那么还真不知道他说的第个步骤是什么意思
    另外,没有auto_increment如何合并数据库呢?
    类似于上面说的吗:
    mysql -h host_name -u username -ppassword --force --disable-named-commands IPI <
          ipi.MOUSE.mysql.edited