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?
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
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With