问题
I am using the postgresql (9.4) interactive terminal psql on Windows 8.1 (64 bit). After installing and creating a database and table and inserting data into a row I want to view the data.
However, when I type
SELECT * FROM my_table;
I get an error:
'more' is not recognized as an internal or external command, operable program or batch file.
After adding "C:\Windows\System32;" to my path variable, more works in Powershell (e.g. more hello.txt) but still not in psql.
What else do I need to do to make the SELECT statement work?
回答1:
It sounds like the way you are launching psql, C:\Windows\System32 is not actually on the PATH in the resulting environment.
You can download something like Process Explorer and use it to look at the environment variables for the running psql process and see if that path is present.
If not, you could make sure it's set in the shell from which psql is invoked, set it as a system environment variable, set PATH accordingly in a cmd file and then invoke psql, etc.
set PATH=%PATH%;C:\Windows\System32
回答2:
Typically this error occurs due to PATH environment variable is not set properly in your system & it is unable to find the more command from
C:\Windows\System32.
The solution to this is:
(Right Click on) My Computer -> Properties -> Advanced tab -> Environment Variable ->
Then set the PATH in system variables.
Add these to the PATH variable:
%SystemRoot%;%SystemRoot%\system32;%PROGRAMFILES%\PostgreSQL\9.4\bin
Hope this will solve your problem.
回答3:
Keep below contains in create_PG_script.bat file
///////////////////////////////////////////
@echo off
setlocal
set PATH=%PATH%;C:\Windows\System32
set PGPASSWORD=yourpasswordcomeshere
"C:\PostgreSQL\9.5\bin\psql.exe" -h localhost -U postgres -d postgres -p 5432 -f D:/PG_Script/select_query.sql"
pause
endlocal
//////////////////////////////////////////////
Also create separate select_query.sql file same location keep
//////////////////////////////////////////////
select * from company;`enter code here`
//////////////////////////////////////////////
run the create_PG_script.bat file
回答4:
We need to set the path :-
"more" exists in C:\Windows\System32. So, please set the path in PATH Environment Variable. and then try. My Computer (Right Click) -> Properties -> then go to Advanced tab -> Environment Variable -> set the path.
回答5:
set the path for the psql in PC settings(right-click)->environment variables->system variables->path(click edit)->" C:\Program Files\Postgresql\12\bin;C:\Program Files\Postgresql\12\lib " now check on the terminal one more time
Still, this problem occurs check on c>windows>system32>
I hope this will help you.
来源:https://stackoverflow.com/questions/27714719/psql-more-is-not-recognized-error