Well, the second example is just embedding a ridulous sub-query in your outer query. The way that SQL semantics work, if you say you are selecting from 2 tables and don't specify a correspondance between the rows of one and the rows of the other, then the result is the
of the rows in each table. If you do this with several tables (or, as in my example, several occurnces of the same table), then the resulting cartesian product is the size (in rows) of the product of the sizes (in rows) of all the tables.
So let's say in our example that your table has only 100 rows in it... by joining it on itself 10 times over, you get one google (10 to the 100th power) of rows. By telling the database to take a minimum value out of those 1 google rows, you would lock up the database for, well, basicaly for ever, sorting through all of those rows. This would essenially deny service to your database until an administrator killed that query.
Anyways, the point of the second example was: some database drivers, such as DBD::Oracle, do not allow you to embed multiple queries in a single DBI call, even if you put a semi-colon in there. I was just demonstrating a way that DBD::Oracle is still suceptible (spelling?) to attack through "SQL injection" (which, if I recall correctly, is the proper term for this form of attack).
------------
:Wq
Not an editor command: Wq
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.