The relational model does not care one tiny little bit what order columns are in within a table, nor (without an ordering clause) what order rows are returned.
Your requirement makes little sense. What if the first column were a varchar
or a date
?
The whole point of having named columns is that you reference them by name.
Now DBMS' often contain metadata in system tables, like DB2's sysibm.systables
and sysibm.syscolumns
, but you need to extract not just the names but all the other metadata as well (column type, size, nullable, and so on) in order to use them properly. We'd probably understand better what you were after if you told us the reason behind doing this.