Simon Slavin <slav...@bigfraud.org> писал(а) в своём письме Wed, 11 May 2011 
22:31:54 +0600:

> That would be purely for a free-format presentation of the entire data in a 
> row.  That's ideal for a utility.  Normally when you write a database 
> application you're specifically looking up some data: the name and phone 
> number of a particular customer, or something.

Not the entire data "for utility"; only needed columns, for specific interface 
a customer deals with.

But what if you need only five columns to display, and your table consists of 
10 columns, does such kind of economy ("SELECT column1,column2,...columnN" 
instead of "SELECT *") make much sense? You don't read the whole table anyway, 
only a small subset of rows, so you won't waste much memory on these "unneeded" 
columns. The speed of the query also won't change if you use "*". In fact, it 
can become even faster because SQL server doesn't have to parse and validate 
the list of columns you've specified. :)

> You're using there ... I'm guessing it's PHP, using an object model.  Which 
> works out the names of the columns for you and makes them available.  What 
> most people get back from "SELECT *" is a list of unlabelled variables.  So 
> they have to remember that item 1 is 'id', item 2 is 'name', item 3 is 
> something they don't actually need right now, item 4 is 'phoneNumber'.  Then 
> you add a new field of 'schoolAddress' and now 'phoneNumber' is actually 
> column 5, not column 4.

You're right, it's PHP, but no, it's not an object model. Just pure PHP (or 
pure PHP + small framework) in most of my apps. Even if you don't use heavy 
instruments like OOP, ORM etc, PHP still allows you to address columns in a 
nice way, i.e. $row["name"]. I'm quite surprized that other programming 
languages still force you to use numeric indices. Indeed "SELECT *" shouldn't 
be used under such circumstances.

> We're not saying there no place for '*', merely that it shouldn't be used 
> unless you actually want '*'.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to