PostgreSQL – Understanding `TABLE example` Syntax

postgresqlsyntax

In PostgreSQL, I've been using syntax like

TABLE example1
UNION ALL
TABLE example2

which I understand to be equivalent to

SELECT * FROM example1
UNION ALL
SELECT * FROM example2

But a colleague asked me questions about this, and I can't find any PostgreSQL docs on this syntax. ("TABLE" isn't a helpful search phrase.) Where can I find documentation about it?

Is it ANSI SQL standard?


EDIT: It currently apparently even confuses StackExchanges's syntax highlighting.

Best Answer

It's documented with the SELECT statement and it's called "TABLE Command" there.

In the SQL standard it's called an "explicit table":

The <explicit table>

   TABLE <table or query name>

is equivalent to the

   ( SELECT * FROM <table or query name> )


This seems to be part of the standard at least since SQL 1992