1

Can anyone of you please tell me which is the best data type for a surrogate key (number or varchar2)? I have read that surrogate key works best with the number type. But is the performance seriously have major impact with the data types. And is it database dependent too?

reply would be much appreciated!

Gunja
  • 11
  • 1
  • if you only need 2 characters, I'd use CHAR(2) - there's really no point in using VARCHAR for just two chars.... – marc_s Feb 03 '10 at 07:01

1 Answers1

4

A numeric datatype is going to be faster than a varchar in any database that I can imagine -- consider the act of comparing -- but you have to do whatever fits your situation. If varchar makes sense, go for it. If either fits equally well for you, stick with a numeric.

Jay
  • 56,361
  • 10
  • 99
  • 123