This might be a novice question. But sometimes, I find it necessary to use things like (SELECT * FROM A) in doing relational algebra in SQL (instead of using the relation A itself).
For example, when trying to work on the UNION of two relations A and B having the same structure, the following
SELECT * FROM (A UNION B) t;
generates a syntax error (with PostgreSQL 9.x).
ERROR: syntax error at or near "UNION"
And I had to do
SELECT * FROM ((SELECT * FROM A) UNION (SELECT * FROM B)) t;
My questions are:
Is the verbosity of the subquery (SELECT * FROM A) really necessary in the SQL language (or am I missing something about better way to write it)? Why can't the relations A and B be used directly here?
Is (SELECT * FROM A) equivalent to A in relational algebra? What does the expansion (SELECT * FROM A) buy us? When is the long form required?