If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Type of tel_no with comma “,“ or space or line “-“

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-29-12, 12:13
Asmaa Asmaa is offline
Registered User
 
Join Date: Dec 2011
Posts: 10
Question Type of tel_no with comma “,“ or space or line “-“

Hi
What is the type of telephone number with comma between the numbers for easy reading?
I don’t want to use “char” for this purpose. Can we do it using integer as its type?
Like 0303-662-2191

Code:
CREATE TABLE Tel
(
Tel_no int    (I don’t want to use char!)
);
INSERT INTO Tel
(
0303-662-2191
);
Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 01-29-12, 12:44
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
No, you have to use varchar if you want to store a formatted telephone number.

Actually there is no other datatype suitable to store a phone number.

Note that char is indeed a bad choice because it is padded to it's length. There is hardly ever a reason to use char over varchar.
Reply With Quote
  #3 (permalink)  
Old 02-13-12, 15:06
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
And in addition, note that a numeric datatype won't work for another reason, as it will not acknowledge leading zeros when entered. (They are dropped.) So, your example of 0303-662-2191, would be stored as 3036622191.

But, you should be able to strip out non-numeric characters using rules or triggers...
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On