Yesterday a colleague showed me the following postgres query. We were both surprised that it worked:
SELECT* FROM mytable;
Since I recently coded a parser for another language, I am trying to understand in more depth why this query "compiles" and returns the same results as SELECT * FROM mytable;
.
Presumably this is recognized as a valid query because during lexical analysis, postgres reads SELECT
from input as a token, and then searches for the next token, which it finds as *
, and so on - is that more or less what is going on here?
Also, does the postgres lexer/parser just happen to be robust enough to understand this query, or would other databases understand a similar SELECT*
query?