Getting empty rows from "SELECT ALL" query in PostgreSQL

Viewed 283

I'm using PostgreSQL server on my Windows. I have created table user(id, name, age) and inserted some data there.
When I'm trying to retrieve that data via SELECT ALL FROM user I'm getting only the rows count and just plain nothingness.

How it looks like in psql CLI:
cmd

...and I'm also receiving empty object array as query result in my nodejs app:
enter image description here

2 Answers

Postgres supports SELECT ALL as a synonym for SELECT -- as a two words syntax parallel to SELECT DISTINCT. The ALL does nothing.

In addition, Postgres -- unlike other databases -- allows a SELECT to select no columns.

So:

SELECT ALL
FROM user;

Selects all the rows from user but no columns. In general, you would instead write:

SELECT *
FROM user;

to see the contents of the rows. If you want to be verbose, yo could use:

SELECT ALL *
FROM user;

But that is used somewhere close to never in practice.

You specified that you want the data from the column named "all". To get data from all columns you need to specify them all or use the asterisk symbol like so:

SELECT * FROM "user";
Related