我有一个带有外键 type
的表,它链接到表 wp_types
。每当我尝试向该表中插入一行时,我都会收到错误消息:
ERROR: permission denied for schema base
LINE 1: SELECT 1 FROM ONLY "base"."wp_types" x WHERE "id" OPERATOR(p...
^
QUERY: SELECT 1 FROM ONLY "base"."wp_types" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x
查询正在作为 postgres 执行。 我也不明白这个查询试图做什么,它显然与检查外键约束有关,但我不明白如何做。
最佳答案
来自 postgresql 文档:
If ONLY is specified, only that table is scanned. If ONLY is not specified, the table and all its descendant tables (if any) are scanned.
正如您提到的,错误与检查外键有关。当指定 ONLY 时,postgres 无法检查它们,这可能会导致错误。
关于sql - Postgres : Inserting rows into table with foreign key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20449651/