Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Primary Key of type string ?
On May 31, 11:03 am, "Oriane" <ori..._at_guermantes.fr> wrote:
> Hi there,
>
> Just a basic question from a beginner in Oracle. Is is the "standard choice"
> to use a column of type "int" for the primary key ? I suppose that this is a
> performance issue ? What about choosing a type "string/char" for a primary
> key ?
>
> Sincerely
>
> Oriane
The standard choice is a number(10). Int is a non-existing datatype in
Oracle and will be automagically translated to number(39).
Numbers are stored packed, two digits in a byte.
Choosing string/char is a bad idea.
First of all, it will take more space, but secondly string comparisons
are internally more expensive: the string will be compared until the
first pair of characters that is different.
Do *NOT* store numbers padded with zeroes in a string!
This will result in much more I/O and all of your code is sensitive to
implicit type conversion, and Oracle will always convert the database
column to the variable, thus suppressing index usage.
-- Sybrand Bakker Senior Oracle DBAReceived on Thu May 31 2007 - 04:26:46 CDT
![]() |
![]() |