Making a basic query on PSQL does not display anything

You need to terminate the query with ;

SELECT * FROM myTable;


There is actually a less obvious cause of the above. If you've ommitted a closing bracket ()) somewhere in the query, you'll get the same behaviour. E.g.

SELECT *
    FROM some_table
    WHERE (NOW() - date_value;

It won't attempt to execute the statement until it gets a closing ); before it spits out a syntax error. While the above is fairly obvious where the issue it, it gets a lot trickier to spot with more complex queries. To get out of it, close with multiple brackets ))))))))); which will still resolve and spit out the syntax error so you can continue and correct.

A way to spot if this is the case, is to use the Up arrow through your history - if you're not seeing your previously typed (but not yet executed) statements, then you know you're still in a state where it's trying to close the statement before attempting a syntax check.

The issue isn't limited to brackets, but any other closing symbol such as quotes. The trick is to pay attention to the psql prompt as it shows the parsing state. E.g.;

  • DATABASE=> the => means all is normal and it's parsing a single line
  • DATABASE-> the -> means you're on a new line and likely missing a ;
  • DATABASE(> the (> means you haven't closed a bracket
  • DATABASE'> the '> means you haven't closed a quote.

Etc, you get the idea.