PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Sorting Tables
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Sorting Tables

Réponse
 
LinkBack Outils de la discussion
Vieux 31/12/2007, 18h51   #1
Victor Subervi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Sorting Tables

Hi;
Is it possible to sort tables within a given database? How?
TIA,
Victor

  Réponse avec citation
Vieux 31/12/2007, 19h59   #2
mos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sorting Tables

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
  Réponse avec citation
Vieux 02/01/2008, 15h17   #3
Victor Subervi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sorting Tables

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
>
>


  Réponse avec citation
Vieux 02/01/2008, 15h51   #4
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sorting Tables

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
> >
> >

>

  Réponse avec citation
Vieux 02/01/2008, 17h07   #5
Victor Subervi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Sorting Tables

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
> > >
> > >

> >

>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h57.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18701 seconds with 13 queries