joedenly
joedenly

Reputation: 413

Datatype for phone numbers in postgresql

I am new to postgresql so can anyone tell me that is there any specific datatype to store phone numbers in postgresql while creating table in pgadmin or is it just string?

Upvotes: 14

Views: 51548

Answers (2)

Laurenz Albe
Laurenz Albe

Reputation: 246643

I recommend to use text and add a check constraint that tests the phone number for validity.

This is a good use case for domains. Particularly if you need such a column in several places, it is convenient to have a domain that includes the check constraint.

Upvotes: 25

Karamdeep Singh
Karamdeep Singh

Reputation: 324

You can store contact number in BIGINT and VARCHAR.

But with a trade off between security and performance. If you bother about performance (using a big dataset) then you should choose bigint but do read this first Google says never store phone numbers as numeric data If you do not bother about performance as data set is not soo large then go with varchar.

src - [ https://www.mayerdan.com/programming/2017/06/26/db_phone_types ]

Upvotes: 6

Related Questions