将数据从一个 Informix 数据库复制到另一个 Informix 数据库的脚本

发布于 2024-07-24 10:31:03 字数 94 浏览 9 评论 0原文

我需要将数据从一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦幻之岛 2024-07-31 10:31:03

如果没有关于您所拥有的 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.

自我难过 2024-07-31 10:31:03

最简单的解决方案是备份数据库实例并将其恢复到单独的实例。 如果这对您来说不可能,那么还有其他可能性。

  • dbexport/dbimport
  • 卸载/加载
  • 手工制作的 SQL 插入

如果数据库结构相同,则可以使用 dbexport/dbimport,但这会将数据卸载到文件系统或磁带上的平面文件,然后从平面文件导入。

我通常发现如果数据库结构相同,那么加载/卸载是最简单的解决方案。

如果您不想使用加载/卸载 dbimport/dbexport 那么您可以使用直接 SQL INSERTS,如下所示(未经测试,您将需要检查语法)

INSERT INTO dbname2@informix_server2:table
SELECT * FROM dbnam1e@informix_server1:table_name

这当然意味着一致的表结构,如果结构是一致的,您可以使用列列表是不同的。

会给您带来问题的一个领域是引用完整性。 如果您有外键,那么这会给您带来问题,因为您需要确保插入以正确的顺序完成。 您可能还遇到 SERIAL 列和 INSERTS 的问题。 Load 不会遇到此问题,因为您可以将序列值加载到表中并保留原始值。

我经常发现最好的解决方案如下

  • 从数据库1中获取模式。
  • 最初将其分成两部分
    段是所有表创建
    陈述,第二部分是全部
    CREATE INDEX 的,参考
    诚信等声明。
  • 从第一部分创建数据库2
    架构。
  • 使用 UNLOAD/LOAD 将数据加载到
    数据库2.
  • 将架构的第二部分应用于database2

这与 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.

  • dbexport/dbimport
  • unload/load
  • hand-crafted SQL inserts

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)

INSERT INTO dbname2@informix_server2:table
SELECT * FROM dbnam1e@informix_server1:table_name

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

  • Take a schema from database1.
  • Split it into 2 parts the initial
    segment is all table creation
    statements, the second parts is all
    of the CREATE INDEX, referential
    integrity etc statements.
  • Create database2 from the 1st part of
    the schema.
  • Use UNLOAD/LOAD to load the data into
    database2.
  • Apply the second part of the schema to 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.

淡写薰衣草的香 2024-07-31 10:31:03

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文