Updated November, 23 2023

SQL Aliases#

For each subquery, we add an alias if it doesn’t exist. DTA$<index>

1--Oracle
2SELECT 1 FROM (SELECT 1 FROM DUAL);
3
4
5--PostgreSQL:
6SELECT 1 FROM (SELECT 1 FROM DUAL) DTA$1;

We add AS keyword before SELECT item alias if it was missed.

1--Oracle
2SELECT 1 ONE FROM DUAL;
3
4
5--PostgreSQL
6SELECT 1 AS ONE FROM DUAL;

Issues

For missed select item aliases we should add aliases with names equal to the select item expression.