Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Database Record Order

by edoc (Chaplain)
on Dec 30, 2003 at 22:20 UTC ( #317794=note: print w/replies, xml ) Need Help??


in reply to Database Record Order

The data, which perl outputs isn't in the same order as the database.

The database has no inherent order. You must consider query results as being returned from the database in random order (much like keys from a hash) unless you specify an 'order by' clause.

cheers,

J

Replies are listed 'Best First'.
Re: Re: Database Record Order
by monktim (Friar) on Dec 31, 2003 at 14:12 UTC
    That depends on the DBMS you are using. When the ORDER BY clause is not specified, some dBs return the data in the order it was inserted into the tables. You'll have to read your dB's documentation to be certain.
      If this is an MS-SQL server then the "default" order is likely to be the order of the clustered index. However, relying on that ordering when using an RDBMS is unwise, as it could change at any time, or be different if you move your script from one type of database server to another, or if other DDL changes (such as different indexes, different locking methods, etc) are applied.

      In short - never rely on the order of data in a SELECT without an ORDER BY clause.

      Michael

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://317794]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-01-17 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (50 votes). Check out past polls.

    Notices?