File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Database Index

 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33689
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot for the promt replies
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic