wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes Regarding Database Index Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 32635
    
215

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.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Priyakant Charokar
Ranch Hand

Joined: May 08, 2004
Posts: 58

Thanks alot for the promt replies
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Database Index
 
jQuery in Action, 3rd edition