At 12:51 PM 12/31/2007, you wrote:
Hi;
Is it possible to sort tables within a given database? How?
TIA,
Victor

Victor,
You mean physically sort the table based on a field or key so you don't have to do an Order By clause each time you do a Select? Not really because the order of the table is expected to be random unless you specify an Order by clause. The only thing I can think of is to create a new table, maybe temporary or Memory table and copy the data into it already sorted.

drop table if exists newtable;
create newtable like oldtable;
insert into newtable select * from oldtable order by col1, col2;

Now you should be able to

Select * from NewTable;

without sorting (if you don't update it). The order should be by col1,col2. (No guarantee)

If you want to sort it in order to speed it up, then run an Optimize on the table.

Mike
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to