dbTalk Databases Forums  

Index a table created with a select

comp.databases.mysql comp.databases.mysql


Discuss Index a table created with a select in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joseph Hesse
 
Posts: n/a

Default Index a table created with a select - 08-09-2011 , 10:54 AM






I am creating a table with a SELECT statement.
CREATE TEMPORARY TABLE XYZ
(SELECT A.key AS key, otherfields FROM A JOIN B on A.key = B.key);

I want to index the table XYZ on A.key.
Is there a way to indicate in the above that I want an index or do I
have to do an additional
ALTER TABLE XYZ ADD INDEX(key);

Thank you,
Joe

Reply With Quote
  #2  
Old   
Willem Bogaerts
 
Posts: n/a

Default Re: Index a table created with a select - 08-10-2011 , 02:23 AM






On 09/08/11 17:54, Joseph Hesse wrote:
Quote:
I am creating a table with a SELECT statement.
CREATE TEMPORARY TABLE XYZ
(SELECT A.key AS key, otherfields FROM A JOIN B on A.key = B.key);

I want to index the table XYZ on A.key.
Is there a way to indicate in the above that I want an index or do I
have to do an additional
ALTER TABLE XYZ ADD INDEX(key);

Thank you,
Joe
You can state an index and even additional fields in the create
statement. See the manual.

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/

Reply With Quote
  #3  
Old   
onedbguru
 
Posts: n/a

Default Re: Index a table created with a select - 08-10-2011 , 05:27 PM



On Aug 9, 11:54*am, Joseph Hesse <j... (AT) gmail (DOT) com> wrote:
Quote:
I am creating a table with a SELECT statement.
CREATE TEMPORARY TABLE XYZ
(SELECT A.key AS key, otherfields FROM A JOIN B on A.key = B.key);

I want to index the table XYZ on A.key.
Is there a way to indicate in the above that I want an index or do I
have to do an additional
ALTER TABLE XYZ ADD INDEX(key);

Thank you,
Joe
There is also the ANSI Standard "create index idx_name on tablename
(colname,,,)"

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.