小编Sup*_*are的帖子

PostgreSQL中的外键+表继承?

我有三个表:organization,organization_teamsorg_users.这organization_teams是继承自organization.因此,假设如果在organizations_teams其中添加记录将使organization表格id成为id列中的值organization_teams.

org_usersid列上有外键organization.现在,当我尝试在其中插入数据时org_users,给出了如下错误

insert or update on table "org_users" violates foreign key constraint "org_users_organizations"
DETAIL:  Key (org_id)=(12) is not present in table "organizations"
Run Code Online (Sandbox Code Playgroud)

为什么?

postgresql inheritance

18
推荐指数
1
解决办法
8411
查看次数

标签 统计

inheritance ×1

postgresql ×1