我有两个不同的数据库,两个数据库都有主要的测试平台,但并不是所有列都相同。我已经提到了两个表的示例案例。
所以,我的要求是:
每当更新后在db1.primary_testbed表中更新“PrimaryTestbed”列时,db2.primary_testbed中的列“PrimaryTestinfo”还需要更新完全匹配的表吗?
这就是我试过的: -
DELIMITER $$
CREATE TRIGGER PRIMARY_TESTBED_AFTER_UPDATE
AFTER UPDATE ON db1.primary_testbed
FOR EACH ROW
BEGIN
UPDATE db2.primary_testbed
SET PrimaryTestinfo = NEW.PrimaryTestbed
# how to put where clause here?
END$$
DELIMITER ;
以下是我的表格: -
1)db1.primary_testbed
*************************************************************************************
|Branch | Model | Tool | Protocol | Ratio | PrimaryTestbed| HostName |
*************************************************************************************
| rel-A | MN100 | tool1 | IO | 0 | arr-1 | xxxxxxx |
*************************************************************************************
| rel-B | LK4000 | tool2 | CSID1 | 2 | arr-230 | yyyyyyy |
*************************************************************************************
| rel-A.1.0 | JP5000 | tool2 | IO | 1 | arr-500 | xxxxxxx |
*************************************************************************************
| rel-B.1.0 | MN1000 | tool1 | IO | 5 | arr-220 | xxxxxxx |
*************************************************************************************
| rel-C | DQ3000 | tool1 | CSID1 | 0 | arr-100 | xxxxxxx |
*************************************************************************************
| rel-A.2.0 | MN100 | tool2 | CSID1 | 10 | arr-600 | zzzzzzz |
*************************************************************************************
2)db2.primary_testbed
**********************************************************************
| Release | Model | Tool | Protocol | Ratio | PrimaryTestinfo|
**********************************************************************
| rel-A | MN100 | tool1 | IO | 0 | arr-1 |
**********************************************************************
| rel-B | LK4000 | tool2 | CSID1 | 2 | arr-230 |
**********************************************************************
| rel-A.1.0 | JP5000 | tool2 | IO | 1 | arr-500 |
**********************************************************************
| rel-B.1.0 | MN1000 | tool1 | IO | 5 | arr-220 |
**********************************************************************
| rel-C | DQ3000 | tool1 | CSID1 | 0 | arr-100 |
**********************************************************************
| rel-A.2.0 | MN100 | tool2 | CSID1 | 10 | arr-600 |
**********************************************************************
我们将不胜感激。
先谢谢。