可以从表中进行选择,但不能对其进行更新(尝试进行更新时获取“关系[表名]不存在]” >> [

问题描述 投票:1回答:2
[当我尝试使用Dbeaver中的批处理执行来更新表中的几列时,update语句适用于第一列(第一个执行),但是随后其余列的所有后续执行都抛出了“ relation nat_res_minerals_mrds_v2不存在”错误。

但是,当我使用相同的表名执行选择查询时,不会发生错误,并且我的数据也很好。

我检查了所有约束,找到了两个约束并删除了其中一个-但是约束之一以数字开头,因此当我尝试删除它时(即使在列名两端加上双引号“”时),我也会得到一个“约束不存在”错误。

因此,我尝试通过将数据选择到新表中来解决此问题,检查是否保留了任何约束(它们没有),但是问题仍然存在。

此外,有趣的是,尽管第一个更新语句起作用了,但是随后在同一列上执行相同更新语句的后续尝试现在引发了“关系nat_res_minerals_mrds_v2不存在”错误。

我不确定如何继续,特别是因为第一个更新语句有效,并且从表中进行选择始终有效并且继续有效。

任何输入将不胜感激。

编辑:

这里是实际查询:

update nat_res_minerals_mrds_v2 n set mdscr1 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m1 and n.m1<>''; update nat_res_minerals_mrds_v2 n set mdscr2 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m2 and n.m2<>''; update nat_res_minerals_mrds_v2 n set mdscr3 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m3 and n.m3<>''; update nat_res_minerals_mrds_v2 n set mdscr4 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m4 and n.m4<>''; update nat_res_minerals_mrds_v2 n set mdscr5 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m5 and n.m5<>''; update nat_res_minerals_mrds_v2 n set mdscr6 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m6 and n.m6<>''; update nat_res_minerals_mrds_v2 n set mdscr7 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m7 and n.m7<>''; update nat_res_minerals_mrds_v2 n set mdscr8 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m8 and n.m8<>''; update nat_res_minerals_mrds_v2 n set mdscr9 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m9 and n.m9<>''; update nat_res_minerals_mrds_v2 n set mdscr10 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m10 and n.m10<>''; update nat_res_minerals_mrds_v2 n set mdscr11 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m11 and n.m11<>''; update nat_res_minerals_mrds_v2 n set mdscr12 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m12 and n.m12<>''; update nat_res_minerals_mrds_v2 n set mdscr13 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m13 and n.m13<>''; update nat_res_minerals_mrds_v2 n set mdscr14 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m14 and n.m14<>''; update nat_res_minerals_mrds_v2 n set mdscr15 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m15 and n.m15<>''; update nat_res_minerals_mrds_v2 n set mdscr16 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m16 and n.m16<>''; update nat_res_minerals_mrds_v2 n set mdscr17 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m17 and n.m17<>''; update nat_res_minerals_mrds_v2 n set mdscr18 = x.code_dscr from xwalk_nat_resources_minerals_codelist x where x.code = n.m18 and n.m18<>''; select * from nat_res_minerals_mrds_v2;

[当我尝试在Dbeaver中使用批处理执行更新表中的几列时,update语句适用于第一列(第一个执行),但随后的所有后续执行都适用于其余的列...
postgresql sql-update constraints
2个回答
0
投票
您缺少select语句。

0
投票
在不进行任何更改之后,这些查询现在可以正常工作。谁知道...
© www.soinside.com 2019 - 2024. All rights reserved.