aspose file tools*
The moose likes JDBC and the fly likes Regarding Database Index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Regarding Database Index" Watch "Regarding Database Index" New topic
Author

Regarding Database Index

Priyakant Charokar
Ranch Hand

Joined: May 08, 2004
Posts: 58

Does creating a table automatically creates index on the column.
I mean if I will create a table
create table.....(id, name)
Will this automatically be indexed on id and name ?


SCJP, SCWCD, SCMAD, SCEA, OCPJP 7, CSM
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No. Nor should it be. Indices incur a decrease in insert/update/delete performance so you wouldn't want them added by default.

Some database s (such as SQL Server) will automatically create indices on columns that are foreign keys. Other than that by and large its up to you to choose what to index.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

Priyakant,
Many databases automatically create an index on the primary key (likely id in your example.)

There would be no point in creating an index on all the columns in the table - automatically or manually. The reason is that such an index would be just as large as the source table. Which means it would take just as long to scan as the table.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Priyakant Charokar
Ranch Hand

Joined: May 08, 2004
Posts: 58

Thanks alot for the promt replies
 
jQuery in Action, 2nd edition
 
subject: Regarding Database Index