This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Numeric or varchar2? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Numeric or varchar2?" Watch "Numeric or varchar2?" New topic
Author

Numeric or varchar2?

Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92
which one of the following will be more faster and suitable for Primary Key with respect to Oracle 10g Database?
1. Numeric Field
2. Varchar2 Field

Regards
Prithiraj
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

Prithiraj,
The choice should depend on what form of key data you have. If is a number, use the numeric type. Otherwise, use the varchar type. Both are suitable. If you want an auto-incrementable key, numeric is preferred.

For speed, both can perform well since the primary key will be indexed.


[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
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
In general, a numeric surrogate key is faster.
 
wood burning stoves
 
subject: Numeric or varchar2?