aspose file tools
The moose likes JDBC and Relational Databases 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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Numeric or varchar2?" Watch "Numeric or varchar2?" New topic

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

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31682

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.

[OCA 8 book] [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:
subject: Numeric or varchar2?