|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi;
Is it possible to sort tables within a given database? How? TIA, Victor |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Either I don't understand your reply or I miscommunicated. How do I do that
when it is the tables that I want to select; that is *all* tables that are called "xyz$variable", where "variable" is unknown but all tables begin "xys$"? TIA, Victor On Dec 31, 2007 3:59 PM, mos <mos99@fastmail.fm> wrote: > 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/mysql?unsub=v...ervi@gmail.com > > |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Hi,
Try this: SHOW TABLES LIKE 'xyz%'; Baron On Jan 2, 2008 10:17 AM, Victor Subervi <victorsubervi@gmail.com> wrote: > Either I don't understand your reply or I miscommunicated. How do I do that > when it is the tables that I want to select; that is *all* tables that are > called "xyz$variable", where "variable" is unknown but all tables begin > "xys$"? > TIA, > Victor > > On Dec 31, 2007 3:59 PM, mos <mos99@fastmail.fm> wrote: > > > 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/mysql?unsub=v...ervi@gmail.com > > > > > |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Ah, yes. Thank you.
On Jan 2, 2008 11:51 AM, Baron Schwartz <baron@xaprb.com> wrote: > Hi, > > Try this: > > SHOW TABLES LIKE 'xyz%'; > > Baron > > On Jan 2, 2008 10:17 AM, Victor Subervi <victorsubervi@gmail.com> wrote: > > Either I don't understand your reply or I miscommunicated. How do I do > that > > when it is the tables that I want to select; that is *all* tables that > are > > called "xyz$variable", where "variable" is unknown but all tables begin > > "xys$"? > > TIA, > > Victor > > > > On Dec 31, 2007 3:59 PM, mos <mos99@fastmail.fm> wrote: > > > > > 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/mysql?unsub=v...ervi@gmail.com > > > > > > > > > |
|
![]() |
| Outils de la discussion | |
|
|