简体   繁体   English

使用 Pentaho 勺子复制到 MySQL 目标数据库后,从 MySQL 源数据库表中删除记录

[英]Delete records from MySQL source database table ,after copying to MySQL target database using Pentaho spoon

I would like to do the below operation using Pentaho spoon/PDI.我想使用 Pentaho 勺子/PDI 进行以下操作。

  1. Copy data from the Mysql source database to the Mysql target database.将数据从 Mysql 源数据库复制到 Mysql 目标数据库。 2)After that I would like to truncate/Delete Data from Source Database 2)之后我想从源数据库中截断/删除数据

Can Someone help with this?有人可以帮忙吗?

Just run two transformations and one job:只需运行两次转换和一项工作:

  1. First transformation: Table input step to read table data from source database and Table output step to write said data to table in target database第一次转换:从源数据库读取表数据的表输入步骤和将所述数据写入目标数据库表的表 output步骤
  2. Second transformation: Truncate table in Source database.第二次转换:截断源数据库中的表。 I don't remember if there's a specific step for this or if you could use a job step instead of a transformation running a SQL script to truncate the table.我不记得是否有特定的步骤,或者您是否可以使用作业步骤而不是运行 SQL 脚本的转换来截断表格。 Just check what you have available in Pentaho, I don't have it opened at the moment to verify.只需检查您在 Pentaho 中可用的内容,我目前还没有打开它来验证。
  3. Job: After successfully running First transformation run the second transformation or the step.作业:成功运行第一个转换后,运行第二个转换或步骤。

Now, you can complicate matters from this depending on your situation:现在,您可以根据自己的情况使问题复杂化:

  • Do you need to replicate a whole database instead of just one table?您是否需要复制整个数据库而不仅仅是一个表? You'll need to add steps to work with Metadata Injection, so you run the first a second transformations for all the tables in the source database.您需要添加使用元数据注入的步骤,因此您需要为源数据库中的所有表运行第一个和第二个转换。 You can read the dictionary tables in the source database to inject the information about table names and columns to the transformations so you don't create one pair of transformations for each table.您可以读取源数据库中的字典表,以将有关表名和列的信息注入到转换中,这样您就不会为每个表创建一对转换。
  • Do you need to create the tables in the target database before populating them?在填充它们之前是否需要在目标数据库中创建表? You'll need to add additional transformations to read the metadata of the table to create and build the script to create said table in the target database before populating it.您需要添加额外的转换来读取表的元数据以创建和构建脚本,以便在填充之前在目标数据库中创建所述表。

And so on等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM