Postgres数据库错误:关系不存在 [英] Postgres Database Error: relation does not exist

查看:5017
本文介绍了Postgres数据库错误:关系不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修复遗留系统的一些问题,并遇到一个阻碍,我很惊讶,没有抓到更快。我运行Django 1.3和使用postgres 9.1.3运行此应用程序。该系统是一个验证系统,供用户使用系统的其余部分。它使用Django用户界面的一部分,但大多数情况下它有自己的Users。



我的问题出现在我尝试给用户他们的帐户问题(类似于如果你忘记了网站的密码)。当我尝试这样做时会引发此错误:

 数据库错误在admin / password / user 

relationpassword_user_answered_questions_id_s不存在
LINE 1:SELECT CURRVAL('password_user_quest ...
^

有人知道什么可能会导致这个错误?我已经尝试重置数据库(没有想到它会做任何,但只是想确定),还使用phppgadmin在数据库中戳,发现一切都正确存储,除了这一个。它分配它时使用ManyToMany字段,使用户可以有多个问题,一个问题可以由多个用户使用。

解决方案

原因很可能是


关系password_user_answered_questions_id_s


正如错误讯息通知我们。您是否知道 PostgreSQL处理标识符



此外,序列通常命名为 * _ seq

上面的链接:


系统使用的标识符不超过NAMEDATALEN-1个字节;
更长的名称可以用命令写入,但它们将被截断
默认情况下,NAMEDATALEN为64,因此最大标识符长度为 63
字节。如果这个限制有问题,可以通过更改src / include / pg_config_manual.h中的
NAMEDATALEN常量来提高。


大胆强调我。看来您应该缩短标识符。


I am fixing some problems with a legacy system and have run into a snag that I am surprised was not caught sooner. I am running Django 1.3 and using postgres 9.1.3 in running this application. The system is a validation system for users to use the rest of the system. It uses part of the Django users interface, but mostly it has it's own 'Users'.

My problem comes along when I try and give a user their account questions (similar to if you forget a password to a website). When I try to do that it throws this error:

Database Error at admin/password/user

relation "password_user_answered_questions_id_s" does not exist
LINE 1: SELECT CURRVAL('"password_user_quest...
              ^

Does anyone know what might cause this error? I have tried resetting the db (didn't think it would do anything but just wanted to be sure) and have also poked around in the db using phppgadmin and found that everything else is getting stored correctly except this one. It is using a ManyToMany field when assigning it so that a user can have multiple questions and a question can be used by multiple users.

解决方案

The reason is most likely that the

relation "password_user_answered_questions_id_s" does not exist

Just like the error message informs us. Are you aware of how PostgreSQL handles identifiers?

Also, sequences are usually named *_seq. Letters missing from the end?


About maximum length of identifiers - I quote the manual from the link above:

The system uses no more than NAMEDATALEN-1 bytes of an identifier; longer names can be written in commands, but they will be truncated. By default, NAMEDATALEN is 64 so the maximum identifier length is 63 bytes. If this limit is problematic, it can be raised by changing the NAMEDATALEN constant in src/include/pg_config_manual.h.

Bold emphasis mine. Seems like you should shorten your identifiers a bit.

这篇关于Postgres数据库错误:关系不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆