Subject | Does SELECT * result in the column order in which they are in the table/view? |
---|---|
Author | partsi |
Post date | 2010-04-07T15:22:14Z |
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.,
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.
Relying on the correct column ordering is useful when creating a view that selects from different tables that have the same structure. E.g.,
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.