Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Difference betn Select statements


Message #1 by "Balaji" <snbalaji_be@y...> on Thu, 13 Mar 2003 12:57:18
In your example, there is no difference.

The biggest problem with SELECT * is that sometime in the future someone may
come along and insert a new column into the table, potentially reordering
the output columns and breaking all the code that depends upon the
particular order in which SELECT * returned the columns.  By selecting the
individual columns explicitly, you get to control the order they are
returned in the resultset.  You also get to control which columns are
returned; SELECT * returns them all, which is more than you may need.

Some may suggest that SELECT * is less efficient, as the system will have to
determine the all columns involved when the query is compiled.

IMO explicitly specifying the columns is clearer and leaves no doubt as to
what columns are being returned.  The small amount of extra typing to be
explicit is a small price to pay.
--
Jeff Mason              Custom Apps, Inc.
Jeff@c...


-----Original Message-----
From: Balaji [mailto:snbalaji_be@y...]
Sent: Thursday, March 13, 2003 12:57 PM
To: sql language
Subject: [sql_language] Difference betn Select statements


Hi all,

Could any one please let me know the difference between

Select * from <table_name>

and

Select <individual_column_names> from <table_name>

For ex:
Say i have table in the database named "Employee" with 2 columns, "ID"
and "NAME".

Now,
my question is, what is the difference between below 2 statements,

1.  Select * from Employee

2.  Select ID, NAME from Employee

Thanks in advance,


Balaji.SN


  Return to Index