Trying to use “\i [filename]” in psql, getting “invalid argument”

落花浮王杯 提交于 2020-12-07 08:33:07

问题


Using Windows 10, Postgres 11. I have a file C:\Users\myname\some path\query.sql containing a typical SELECT query:

select a.id,m.toagentid,m.maxstart from agent a
left join
mostrecentfromtopair m 
on
a.id=m.fromagentid

When I'm in the psql terminal, and I try to run this query as follows:

\i "C:\Users\myname\some path\query.sql"

then I get this error:

\i: Invalid argument

How should I be running this .SQL file?


回答1:


You can use single quotes and slashes:

\i 'C:/Users/myname/some path/query.sql'


来源:https://stackoverflow.com/questions/53975117/trying-to-use-i-filename-in-psql-getting-invalid-argument

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!