Sign in
Log inSign up
Which one is better for primary key  - INT or Varchar?

Which one is better for primary key - INT or Varchar?

Sivabalan's photo
Sivabalan
·Mar 12, 2016

I searched lot on net. I got the idea that using int as primary key for my table will give more performance on indexing and fast retrieval.

But why do I want to go for Varchar? I have an API for my app. If an intruder finds my response that includes my primary key, they can easily know what is my next record.

Suppose I am using some random number for primary key just like this "BxVaxwuswl" they can't figure out what will be my next record.

Am I going in the right direction? Kindly guide me here.