Naturally, I come up with an example and someone finds the loophole :)
Though exceptions to every rule exist (as you've demonstrated), using "select * from ..." is terrible programming practice. Here are a few ways that can botch things:
- Column gets deleted.
- Column gets added (possibly throwing off the order or columns).
- Columns get reordered.
Virtually any of the above situations have a strong potential to corrupt data in your program. If the "access_level" column gets deleted and moved into a new table, your script won't know that. It won't die on the select and the data may propagate quite a a while through the system before the corruption is detected. Of course, proper validation might stop that, but then, selecting the proper column names will help, too.
The other problem with "select * from..." is that it is usually inefficient. If you only need one or two fields, selecting them directly as opposed to all 30 in a table is going to slow things down.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|