MY first guess is that you simply need an ORDER BY field in yout (later, ad you put it) SELECT.
However, the whole point of using a database such as MySQL is that you do not worry about how exactly your data is stored. there are many different tricks that a database can use to optimise both storage and retrieval, and it is the job of a good DBMS to implement as many of them as it can, and select the appropriate tricks to optimise your queries. However, in order to do this, you have to give it some hints, and the way you do this is by telling it to build indexes based on the fields which you intend to use for SLECTing data or for ORDERing, This allows the database to search un-ordered data in an ordered manner. The database automatically and invisibly maintains an index, or several indexes, on your data as you add and remove records. Once you have created the index, you need take no further action It sounds as if your field should be give a special kind of index called a PRIMARY KEY. This allows the database to ensure that entries ar unique, and to retrieve data very fast when selec ted or ordered by that column. You should search the MySQL manual (and poosibly the net) for "PRIMARY KEY". I think you had the idea oc actually sorting the data in the file. This would be horrendously slow: basically, it would ahve to shuffle on average half the records in the database every time you did an insert or delete. You say that you don't want to sort the records during SELECT. But to do exactly this is what databases are designed to do: to accept data essentially randomy, build and maintain indexes on that data, and use those indexes at SELECT to produce a finely crafted subset of your data. Alec Christoph Lehmann <[EMAIL PROTECTED]> 04/05/2005 00:38 To mysql@lists.mysql.com, [EMAIL PROTECTED] cc Subject Re: newbie: how to sort a database without extracting the data thanks Damian but I don't understand this: My field according to which I want the database to be sorted IS an unique number. eg I have 1 ab 33 1 cd 21 1 ac 32 2 aa 22 2 cd 25 3 kw 03 3 ie 02 2 ei 05 2 wk 00 I need it in the form: 1 ab 33 1 cd 21 1 ac 32 2 aa 22 2 cd 25 2 ei 05 2 wk 00 3 kw 03 3 ie 02 what do you mean by adding an index thanks for your help cheers christoph Damian McMenamin wrote: > add an index on the field. would be quickerthan any exporting > importing. > --- Christoph Lehmann <[EMAIL PROTECTED]> wrote: >>Hi >>I am really new to mysql. I need my database to be sorted according >>to >>one field. But since the database with 12000000 records is huge, I >>don't >>want to do it using SELECT. >>What I need is just the stored database being sorted on hard-disk. Is >> >>there any way doing this like creating a new database and importing >>the >>old one but being sorted? >> >>many thanks for your kind help >> >>cheers >>christoph >> >>(p.s. I need this for later chunk-wise data-fetch with one chunk >>being >>homogenous in regard to one (the sorted) field) >> >>-- >>MySQL General Mailing List >>For list archives: http://lists.mysql.com/mysql >>To unsubscribe: >>http://lists.mysql.com/[EMAIL PROTECTED] >> >> > > Yours Sincerely, > Damian McMenamin > Analyst Programmer > Melbourne > Australia > Cell: (61)040-0064107 > Email: [EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]