Warm tip: This article is reproduced from serverfault.com, please click

Getting empty rows from "SELECT ALL" query in PostgreSQL

发布于 2020-11-28 02:06:39

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

Questioner
Ömer
Viewed
0
Gordon Linoff 2020-11-28 10:25:58

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.