PG :: SyntaxError:ERROR:语法错误在或附近

时间:2017-10-22 16:15:17

标签: ruby postgresql

我正在尝试直接连接到postgres数据库并运行查询。它告诉我表,这是一个视图不存在,但我看到它列出。我错过了什么?

代码

require 'pg'
conn = PG::Connection.open(:dbname => 'mydatabase')

conn.exec("Select * From Distinct_filing_xml_view")

ERROR

PG::UndefinedTable: ERROR:  relation "distinct_filing_view" does not exist
LINE 1: Select * From Distinct_filing_xml_view
                      ^

    from (irb):5:in `exec'
    from (irb):5
    from /Users/aa/.rbenv/versions/2.3.3/bin/irb:11:in `<main>'

res= conn.exec("select table_name from INFORMATION_SCHEMA.views")
res.each {|i| puts i }
{"table_name"=>"Max_filing_xml_view"}
{"table_name"=>"Distinct_filing_xml_view"}
{"table_name"=>"Filing_xml_view"}
{"table_name"=>"select_in_max_subdate_view"}
{"table_name"=>"max_sub_date"}

更新:找到解决方案

res = conn.exec('Select * From "Distinct_filing_xml_view"')

有谁知道为什么需要报价?

0 个答案:

没有答案