Skip site navigation (1) Skip section navigation (2)

Varchar or integer primary key?

From: Rafael Charnovscki <charnovs(at)unesc(dot)rct-sc(dot)br>
To: pgsql-novice(at)postgresql(dot)org
Subject: Varchar or integer primary key?
Date: 2004-07-26 19:08:14
Message-ID: 4105569E.4010101@unesc.rct-sc.br (view raw or flat)
Thread:
Lists: pgsql-novice
I have a 6-digit integer number for a patient identifier which
I intend to use as a primary key (PK) for a table. It also will
be a foreign key in other tables. Do I have to use an integer data
type as a domain for this PK or could I use a varchar(6)?  Is there
any difference between an index on an integer column and one on a 
varchar column?

I've been searching the internet and books for something to help on
this question but I haven't found. There are lot of good discussions on
choosing primary keys but nothing related to my issue.
Any suggestions or references may help.

Thanks in advance,
Rafael



Responses

pgsql-novice by date

Next:From: Scott MarloweDate: 2004-07-26 20:23:09
Subject: Re: Varchar or integer primary key?
Previous:From: Tom LaneDate: 2004-07-26 16:42:57
Subject: Re: [ADMIN] how to find transaction associated with a lock

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group