I’m a self taught developer and ive always been told not to use SELECT *, but most of my queries require to know all the values of a certain row…
what should i use then? should i list ALL of the properties every time? like Select elem1,elem2,elem3,….,elem15 FROM…?
thanks
SELECT * FROM … is not always the best way to go unless you need all columns. That’s because if for example a table has 10 columns and you only need 2-3 of them and these columns are indexed, then if you use SELECT * the query will run slower, because the server must fetch all rows from the datafiles. If instead you used only the 2-3 columns that you actually needed, then the server could run the query much faster if the rows were fetch from a covering index. A covering index is one that is used to return results without reading the datafile.
So, use SELECT * only when you actually need all columns.