sql - Postgres : Inserting rows into table with foreign key

标签 sql postgresql

我有一个带有外键 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/

相关文章:

sql - 如何在Spark SQL查询中定义WINDOWING函数以避免重复代码

ruby-on-rails - Rails 3、will_paginate、随机、重复记录、Postgres、setseed 失败

c# - 将数据库添加到现有 SQL Server 2008

sql - 如何在 Sqlite 中按周号分组并获取周号的开始日期和结束日期?

sql - ORA-30483 : window functions are not allowed here

sql - 整数列是否包含值

json - Play + Anorm + Postgres - 将 json 值加载到案例类中

php - 从不同主机将数据从 Postgresql 传输到 Mysql(从 RoR 数据库到 Wordpress 数据库)

sql - 给定一个用户 ID,获取他们所有的收件人 channel 和最后一条消息预览?

mysql - SQL DML 脚本