gpt4 book ai didi

postgresql - “Error 42P01: relation does not exist”(PostgreSQL 中的非公共(public)模式)

转载 作者:行者123 更新时间:2023-11-29 14:34:20 27 4
gpt4 key购买 nike

我想创建外键,但出现错误 42P01:关系不存在。

我必须架构:public 和 laboratorio。

我的表叫做 procedencias。我想为 solicitantes 表创建一个外键。两者都属于laboratorio schema。甚至目标表字段的自动完成功能也可以找到表。

我看到了:

  • 我可以为公共(public)模式的任何表创建外键。
  • 我无法为 laboratorio 模式的任何表创建 foreing 键。创建外键时出错。

enter image description here

我正在使用 Jetbrains DataGrip 软件。

这是名为“solicitantes”的表的 DDL:

CREATE TABLE laboratorio.solicitantes
(
id_solicitante serial NOT NULL,
nombre_solicitante character varying(100) NOT NULL,
CONSTRAINT solicitantes_pkey PRIMARY KEY (id_solicitante)
)
WITH (
OIDS=FALSE
);
ALTER TABLE laboratorio.solicitantes
OWNER TO roby;

CREATE UNIQUE INDEX solicitantes_id_solicitante_uindex
ON laboratorio.solicitantes
USING btree
(id_solicitante);

CREATE UNIQUE INDEX solicitantes_nombre_solicitante_uindex
ON laboratorio.solicitantes
USING btree
(nombre_solicitante COLLATE pg_catalog."default");

我想我必须指定模式名称,但我不知道在 DataGrip 中的什么地方做。

最佳答案

我在从修改表窗口向自定义架构中的表添加外键时遇到了同样的问题。将架构添加到“目标表”字段也不起作用。相反,我选择了“在编辑器中打开”而不是“在数据库中执行”,并将模式添加到生成的语句中的表名中,它运行良好。

关于postgresql - “Error 42P01: relation does not exist”(PostgreSQL 中的非公共(public)模式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47270100/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com