gpt4 book ai didi

sql - 错误 : cannot ALTER TABLE because it has pending trigger events while attempting to drop a column in a table

转载 作者:行者123 更新时间:2023-11-29 11:59:48 24 4
gpt4 key购买 nike

我在我的 liquibase 变更集中写了一个 sql 标签。此 sql 代码假设在名为“Purchase”的表中进行数据迁移。所以我有以下 sql 查询:

UPDATE purchase
SET location_id = (SELECT location_id FROM shop WHERE shop.id = purchase.shop_id);

然后,

ALTER TABLE purchase DROP COLUMN shop_id;

但是我在尝试执行第二个查询时遇到以下错误,该查询应该删除表 Purchase 中的“shop_id”列

ERROR: cannot ALTER TABLE  because it has pending trigger events

请问这个错误是否抛出,我该如何解决。

在我的liquibase changese中,我的sql标签是这样写的

<sql>
UPDATE purchase
SET location_id = (SELECT location_id FROM shop WHERE shop.id = purchase.shop_id);

ALTER TABLE purchase DROP COLUMN shop_id;
</sql

有人可以帮帮我吗?预先感谢您的帮助

最佳答案

听起来您需要在更改和更新之间提交您的更改。

试试这个:

UPDATE purchase
SET location_id = (SELECT location_id FROM shop WHERE shop.id = purchase.shop_id);
COMMIT;
BEGIN;
ALTER TABLE purchase DROP COLUMN shop_id;

“开始;”是可选的,但听起来您的框架正在使用事务,因此我将其包括在内并进行测试以确保更改实际上“接受”。

关于sql - 错误 : cannot ALTER TABLE because it has pending trigger events while attempting to drop a column in a table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29854664/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com