Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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.

 

 

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