Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Enterprise
Expertise: Intermediate
Feb 21, 2002



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Do Not Use the * with the SELECT Statement in Production Code

When * is used in a select query, it returns all the columns in a table. This approach can be used in a development or testing environment, but it should not be used in the production code.

The main reason it should not be used is that the structure of the table the statement references may change over time and when this happens, there is potential for breaking the code that worked before the table was modified.

Let's take an example. Suppose Movie table has MovieName, Year, and Review columns:
SELECT * from Movie

Should be replaced by:
SELECT MovieName, Year, Review

Specifying the column names also makes code maintenance easier. Another person will not have to guess what the statement returns.
Manish Vashistha
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date