Subject Re: [firebird-support] Does SELECT * result in the column order in which they are in the table/view?
Author Ann W. Harrison
partsi wrote:
> Does SELECT * result in the column order in which they are in the table/view? This seems to be the case but I have not yet found any documents saying that this is true. Is it?
>
> Relying on the correct column ordering is useful when creating a view that selects from different tables that have the same structure. E.g.,

Columns in Firebird have a "position" property that determines
their order in a SELECT *. Normally its the order of definition,
but it can be changed.

> CREATE VIEW V_View1( Col1, Col2, Col3 )
> AS
> SELECT T1.* FROM Table1 T1 UNION ALL
> SELECT T2.* FROM Table2 T2 UNION ALL
> SELECT T3.* FROM Table3 T3 UNION ALL
> SELECT T4.* FROM Table4 T4
>
> Any help appreciated.
>

Don't do that! If someone adds a column to any table, your
view will break. I know it's a lot of typing - use cut and paste -
but name your fields explicitly. Select * is an ugly hack left
over from interactive SQL and has no place in data definitions
or programs.


Good luck,

Ann