Home » SQL & PL/SQL » SQL & PL/SQL » Varchar2 as Primary Keys
Varchar2 as Primary Keys [message #299561] Tue, 12 February 2008 07:45 Go to next message
amardilo
Messages: 37
Registered: February 2007
Member
Hi there.

I am sort of new to Oracle (well worked on it for a year or so now but still learning the basics Shocked ), I was creating a table and using a Number as my Primary key for that table but I was told that this should not be done and I should set my Primary Keys always as Varchar2s the Primary Keys will always be numbers but what should the numbers be stored as?

Is what I have been told true? What are the advantages and disadvantages of using varchar2 instead of number as the datatypes for my primary keys?
Re: Varchar2 as Primary Keys [message #299563 is a reply to message #299561] Tue, 12 February 2008 07:48 Go to previous messageGo to next message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
Sounds to me like someone who doesn't know what they are talking about giving you advice.

You might want to use punctuation so people can understand what you are talking about.
Re: Varchar2 as Primary Keys [message #299564 is a reply to message #299561] Tue, 12 February 2008 07:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You can use number or string to primary key.
It only depends on your data and model.

Regards
Michel
Re: Varchar2 as Primary Keys [message #299568 is a reply to message #299564] Tue, 12 February 2008 07:53 Go to previous messageGo to next message
amardilo
Messages: 37
Registered: February 2007
Member
joy_division wrote on Tue, 12 February 2008 07:48
Sounds to me like someone who doesn't know what they are talking about giving you advice.

You might want to use punctuation so people can understand what you are talking about.


Michel Cadot wrote on Tue, 12 February 2008 07:48
You can use number or string to primary key.
It only depends on your data and model.

Regards
Michel



Thanks for your help everyone.

I was finding it hard to explain what I was told as I could not see a reason for it but I'll try and fix my punctuation in future Embarassed
Re: Varchar2 as Primary Keys [message #299569 is a reply to message #299568] Tue, 12 February 2008 07:55 Go to previous messageGo to next message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
I was just confused as to how many different thoughts were in this line:
Quote:

I was creating a table and using a Number as my Primary key for that table but I was told that this should not be done and I should set my Primary Keys always as Varchar2s the Primary Keys will always be numbers but what should the numbers be stored as?

[Updated on: Tue, 12 February 2008 07:55]

Report message to a moderator

Re: Varchar2 as Primary Keys [message #299572 is a reply to message #299569] Tue, 12 February 2008 08:00 Go to previous message
amardilo
Messages: 37
Registered: February 2007
Member
I just read over my first post and noticed it made little to no sense, but I am glad some people managed to understand it Surprised

Anyway I'll keep my primary key's data type as a number
Previous Topic: DDL Trigger
Next Topic: i was unable to create a materialized view on this view (merged)
Goto Forum:
  


Current Time: Fri Dec 09 00:04:37 CST 2016

Total time taken to generate the page: 0.09785 seconds