英文:
Postgres `\d` shows table but `\d table` does not exist?
问题
我用\d
查询Postgres,得到包括表foo
在内的表列表。
Schema | Name | Type | Owner
--------+------+-------+----------
public | foo | table | postgres
然后我查询\d foo
,得到的回答是:未找到名为"foo"的关系。
当我尝试DROP TABLE foo
时,报错:错误:表"foo"不存在。
添加模式名称也不改变响应。
可能的原因是什么?
在使用ogr2ogr时出现了错误,无论是否使用了-overwrite -lco OVERWRITE=YES
,对于这两种组合,一些人说存在问题,尽管我在过去的几个月里每天都使用这个工具几个小时,但从未遇到过这个问题。
英文:
I query Postgres with \d
and get a list of tables including table foo
.
Schema | Name | Type | Owner
--------+------+-------+----------
public | foo | table | postgres
I then query \d foo
, and get told: Did not find any relation named "foo".
When I then try DROP TABLE foo
, ERROR: table "foo" does not exist.
Adding the name of the scheme does not change the response.
What could be the cause?
The error came about when using ogr2ogr with and without -overwrite -lco OVERWRITE=YES
, and both combinations, which some say has issues, although I have used the tool for hours a day for months without seeing the problem.
答案1
得分: 1
可能在表名中存在隐藏或不可见字符。假设foo
是表名的一部分,您可以使用以下查询列出所有包含该部分的表名:
SELECT oid::regclass
FROM pg_class
WHERE relname LIKE '%foo%';
如果表名中包含空格或奇怪的字符,它将以双引号输出,例如:
"foo "
您可以将带引号的表名复制粘贴到您的DROP TABLE
语句中。
英文:
There are very likely hidden or invisible characters in the table name. Provided that foo
is a part of the table name, you can list all such table names with
SELECT oid::regclass
FROM pg_class
WHERE relname LIKE '%foo%';
If there are any spaces or weird characters in the name, it will be output with double quotes, like
"foo "
You can just copy and paste that quoted name into your DROP TABLE
statement.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论