将数据从一个 Informix 数据库复制到另一个 Informix 数据库的脚本
我需要将数据从一个 Informix 数据库复制到另一个。 我不想使用 LOAD 来执行此操作。 有没有任何脚本可以帮助我解决这个问题? 还有其他方法可以做到这一点吗?
I have a need to copy data from one Informix database to another. I do not want to use LOAD for doing this. Is there any script that can help me with this? Is there any other way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果没有关于您所拥有的 Informix 数据库类型的更多信息,就很难确切地说出什么是最适合您的选择。
如果是少量表和大量数据,请查看 onunload、onload 和/或高性能加载器。 (我假设我们在这里讨论的不是标准引擎。)
另一方面,如果您有很多表并且 HPL 过于繁琐,请查看 myexport/myimport(可在 iiug.org 站点上找到)。 这些是标准 dbexport/dbimport 实用程序的非锁定等效项。
Without a bit more information about the types of Informix databases you have, it's hard to say exactly what the best option is for you.
If it's a small number of tables and large volumes of data, have a look at onunload, onload and/or the High Performance Loader. (I'm assuming we're not talking about Standard Engine here.)
If on the other hand you have lots of tables and HPL will be too fiddly, have a look at myexport/myimport (available on the iiug.org site). These are non-locking equivalents of the standard dbexport/dbimport utilities.
最简单的解决方案是备份数据库实例并将其恢复到单独的实例。 如果这对您来说不可能,那么还有其他可能性。
如果数据库结构相同,则可以使用 dbexport/dbimport,但这会将数据卸载到文件系统或磁带上的平面文件,然后从平面文件导入。
我通常发现如果数据库结构相同,那么加载/卸载是最简单的解决方案。
如果您不想使用加载/卸载 dbimport/dbexport 那么您可以使用直接 SQL INSERTS,如下所示(未经测试,您将需要检查语法)
这当然意味着一致的表结构,如果结构是一致的,您可以使用列列表是不同的。
会给您带来问题的一个领域是引用完整性。 如果您有外键,那么这会给您带来问题,因为您需要确保插入以正确的顺序完成。 您可能还遇到 SERIAL 列和 INSERTS 的问题。 Load 不会遇到此问题,因为您可以将序列值加载到表中并保留原始值。
我经常发现最好的解决方案如下
段是所有表创建
陈述,第二部分是全部
CREATE INDEX 的,参考
诚信等声明。
架构。
数据库2.
这与 dbimport 经历的过程非常相似,但从历史上看,我无法使用 dbimport,因为我的数据库包含另一个数据库的同义词,而 dbimport 确实/不能使用这些数据库。
The simplest solution is to backup the database instance and restore it to a separate instance. If this is not possible for you then there are other possibilities.
If the database structure is identical then you can use dbexport/dbimport, however this will unload the data to flat files, either in the file system or on tape and then import from the flat files.
I generally find that if the DB structure is the same then load/unload is the easiest solution.
If you do not want to use load/unload dbimport/dbexport then you can use direct SQL INSERTS as follows (Untested you will need to check the syntax)
This would of course imply consistent table structure, you could use a column list if the structure is different.
One area that will cause you issues is referential integrity. If you have foreign keys then this will cause you a problem as you will need to ensure the inserts are done in the correct order. You may also have issues with SERIAL columns and INSERTS. Load does not suffer from this problem as you can load into a table with a serial value and retain the original values.
I have often found that the best solution is as follows
segment is all table creation
statements, the second parts is all
of the CREATE INDEX, referential
integrity etc statements.
the schema.
database2.
This is very similar to the process that dbimport goes through but historically I have not been able to use dbimport as my database contains synonyms to another database and dbimport did/does not work with these.
UNLOAD 和 LOAD 是最简单的方法。 通过排除它们,您也排除了 DB-Load 和 DB-Access 以及 DB-Export 和 DB-Import 的使用。 这些是最简单的方法。
如前所述,您可以考虑使用 HPL。
您还可以设置一个 ER 系统 - 它比先卸载后加载更难,但不使用禁止操作。
如果两台机器基本相同,可以考虑onunload和onload; 我不会推荐它。
UNLOAD and LOAD are the simplest way of doing it. By precluding them, you preclude the use of DB-Load and DB-Access and DB-Export and DB-Import too. These are the easiest ways to do it.
As already noted, you could consider using HPL.
You could also set up an ER system - it is harder than UNLOAD followed by LOAD, but doesn't use the verboten operations.
If the two machines are substantially identical, you could consider onunload and onload; I would not recommend it.