Subject | Re: [firebird-support] Does SELECT * result in the column order in which they are in the table/view? |
---|---|
Author | Ann W. Harrison |
Post date | 2010-04-07T15:39:25Z |
partsi wrote:
their order in a SELECT *. Normally its the order of definition,
but it can be changed.
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
> 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?Columns in Firebird have a "position" property that determines
>
> Relying on the correct column ordering is useful when creating a view that selects from different tables that have the same structure. E.g.,
their order in a SELECT *. Normally its the order of definition,
but it can be changed.
> CREATE VIEW V_View1( Col1, Col2, Col3 )Don't do that! If someone adds a column to any table, your
> 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.
>
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