0

I have a test database with some rows in it that I am trying to do a select on.

If I run this statement in an IDE like DataGrip I get back rows:

command:

SELECT * FROM public."Album";

output:

1,For Those About To Rock We Salute You
2,Balls to the Wall
3,Restless and Wild
4,Let There Be Rock
5,Big Ones
6,Jagged Little Pill
7,Facelift
8,Warner 25 Anos
9,Plays Metallica By Four Cellos
10,Audioslave

I'm trying to do the same thing on the psql command line and it's not working.

I connect to the database and to a select on the table it returns nothing:

\c our_db
our_db=# SELECT * FROM "Album"

If I use a semi colon I get an error:

our_db-# SELECT * FROM "Album";
ERROR:  syntax error at or near "SELECT"
LINE 2: SELECT * FROM "Album";

I am new to postgres. I'm on version 12.3. What am I doing wrong?

bluethundr
  • 1,005
  • 17
  • 68
  • 141
  • 2
    Because you didn't enter a semicolon after the first `select` statement, but entered another, psql interpreted the query as `select * from Album select * from Album;`. After entering the first line without the semicolon, psql assumed you weren't done yet. Had you entered a semicolon at that point, your results would have been displayed. – Bill Jetzer Jul 06 '20 at 00:34
  • To add to Bill's comment, the prompt change (from our_db=# to our_db-#) indicates that it thinks you are entering a multi line statement – trajekolus Jul 06 '20 at 00:36
  • OK thanks. When I put a semicolon after each command, I get back an error that says: `ERROR: character with byte sequence 0xef 0xbf 0xbd in encoding "UTF8" has no equivalent in encoding "WIN1252"`. How do I get past this? – bluethundr Jul 06 '20 at 00:38
  • Oh, I had to set `SET CLIENT_ENCODING TO 'utf8';` and then I was able to get rows back on the command line. Thanks for your help guys! If you put your advice into an answer I will accept it. – bluethundr Jul 06 '20 at 00:44

0 Answers0