Does the ANSI SQL Standard specify how columns are named in result sets?
I ask this because I just came across some behavior that surprised me, or went against my expectations.
Given the table: t1 (c1 int)
and this query: select t1.c1 from t1
the results are displayed as follows on all databases I tried it on (SQL Server, Oracle, DB2, mySQL and Sybase):
I would have expected the column heading to be different, as follows:
So, if you say 't1.c1' in the select list, you should see t1.c1 in the column heading in the result set.
Given another table, t2 (c1 int), the column headings in the result set of the query 'select t1.c1, t2.c1 from t1,t2' were the same on all database platforms:
c1 | c1
1 | 2
2 | 3
This strikes me as ambiguous, because how do you know which result column came from which table ? I know that you can use column aliases if you want unique names in your column headings, but is there a good reason why the column headings 't1.c1' and 't2.c1' wouldn't be used by default if you specify 't1.c1' and 't2.c1' as items in your select list?