Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

psql "more is not recognized" error

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?

like image 834
gatlanticus Avatar asked Dec 31 '14 00:12

gatlanticus


4 Answers

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
like image 160
khampson Avatar answered Sep 22 '22 01:09

khampson


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.

like image 30
SAM AB Avatar answered Sep 23 '22 01:09

SAM AB


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

like image 36
Vj Singh Avatar answered Sep 19 '22 01:09

Vj Singh


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.

like image 20
Sachindra N. Pandey Avatar answered Sep 22 '22 01:09

Sachindra N. Pandey