Meaningless Drivel is fun!*
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 Soft Skills this week in the Jobs Discussion 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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Numeric or varchar2?