GBase 8s
适配迁移
文章

删除表记录时,报“692: Key value for constraint ( 主键约束名称 ) is still being referenced.”

发表于2023-04-23 15:22:52211次浏览0个评论

问题描述:

删除表记录时,报“692: Key value for constraint ( 主键约束名称 ) is still being referenced.”

 

解决方案:

删除的记录被外键引用了,故不能删除,如果需要删除该记录,应当先删除外键所在表的该值所有记录,以下语句可获取外键参考所在的表的名称:

select t.tabname 

from sysconstraints c, systables t, sysreferences r

where c.tabid = t.tabid 

and   c.constrid = r.constrid

and  c.constrtype = 'R'

and   r.ptabid = (select tabid from systables where tabname = '主键表名');

评论已关闭