【问题标题】:postgres - select * from existing table - psql says table does not existpostgres - 从现有表中选择 * - psql 说表不存在
【发布时间】:2015-03-30 04:36:43
【问题描述】:

新的 postgres 安装,db 'test',表 'Graeber' 从另一个程序创建。

我想查看“Graeber”表的内容。当我连接到数据库并尝试选择“Graeber”的内容时,应用程序告诉我:ERROR: relation "graeber" does not exist

看截图:

这里有什么问题?

【问题讨论】:

标签: postgresql


【解决方案1】:

尝试添加架构,如下所示:

select *
from public.Graeber

如果这不起作用,那是因为你有一个大写字母所以试试:

select *
from public."Graeber"

希望这会有所帮助。

【讨论】:

  • 谢谢,我遇到了类似的问题。 select * from public."Graeber" 为我工作
  • 似乎表名的大写字母需要用引号括起来......我不需要public. 部分。感谢您的帮助。
  • 谢谢我在 Hive 表中遇到了这个问题,所有这些问题都用大写字母表示。我不明白为什么 Postgres 不会找到它们。
  • 如果您想要一个具有区分大小写的表名和区分大小写列的特定列:SELECT "Graeber"."Name" FROM public."Graeber"
  • select * from "Graeber" 也可以。不用加公众号。
【解决方案2】:

请参阅此示例。

queuerecords=# create table employee(id int,name varchar(100));
        CREATE TABLE


queuerecords=# insert into employee values(1,'UsmanYaqoob');
        INSERT 0 1


queuerecords=# select * from employee;
    id |    name
    ----+-------------
    1 | UsmanYaqoob
    (1 row)

【讨论】:

    【解决方案3】:

    在 cmd 中使用 psql 控制台时,有时可能会忘记添加 ';'在 select 语句的末尾

    示例-1:select * from user #does not give any result back

    select * from user; #this works with ';' at the end
    

    别误会我在 Postgresql 版本 13 中遇到了这个问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-06
      • 2021-05-22
      • 2014-10-15
      • 2014-11-20
      • 2014-05-22
      • 2017-06-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多