Scalable Scalable - 7 months ago 20
SQL Question

Using SELECT * FROM table

I understand that using a SELECT * FROM table is considered a bad practice. One reason behind this is that you are select ALL columns from the table , and in case a the table is modified in future and there are extra columns added, you will be fetching those too, and perhaps will not need those.

Assuming that at the time of writing the SELECT * , first time, there indeed was a need to select all columns.

My Question is : Is there any other reason why it might be a bad practice ?


First thing that comes to my mind is the projection the Wikipedia covers that part pretty nice. And in DBA website you have a nice question about it.

You not only miss control over the columns you will present, you also miss the control over the order of the columns. By specifying them you get to have the full control over the resultset + you optimize its size by the elements you really need.

To answer your question, you also miss the possibility to control the location of each column.

SELECT * FROM table; # it would depend of the table internal order

SELECT Name,Surname,Office FROM table; # you decide which column to show the element

Further documentation reading.