Re: Data Type to store Leading Zero(0)

From: Imre Samu <pella(dot)samu(at)gmail(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Data Type to store Leading Zero(0)
Date: 2021-04-16 13:00:08
Message-ID: CAJnEWwn5eMckuTSWVBCWe4yJ2LtomVNzWYDxYShWbQgxQaFJTQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

> Boolean is not possible as this is phone number.

related:
https://github.com/google/libphonenumber/blob/master/FALSEHOODS.md

*"Phone numbers contain only digits*
*In Israel, certain advertising numbers start with a *. In New Zealand,
non-urgent traffic incidents can be reported by calling *555 from a mobile
phone. Alpha characters may also be used in phone numbers, such as in
1-800-Flowers."*

*Phone numbers are numbersNever try to store phone numbers as an int or any
other kind of numeric data type. You can't do arithmetic on them, and while
007, 07 and 7 are the same number they are not necessarily the same phone
number - in some countries a leading 0 is significant and forms part of the
number itself (see A leading zero in numbers formatted for domestic usage
can always be discarded when dialing from abroad). Moreover, a phone number
may contain other diallable characters (see Phone numbers contain only
digits) or an extension portion, dialled after waiting for a tone.Tip: Use
the library to parse and format numbers to handle this correctly for every
country.*
*"""*

<soumik(dot)bhattacharjee(at)kpn(dot)com> ezt írta (időpont: 2021. ápr. 15., Cs,
15:47):

> Thanks for your mail.
>
>
>
> - smallint will be out of range for this due to number of bytes and
> ideally its behaving same way as any ***int data type.
> - Boolean is not possible as this is phone number.
>
>
>
> Please suggest
>
>
>
> Thanks..
>
>
>
>
>
> *From:* Nidhi Gupta <nidhig631(at)gmail(dot)com>
> *Sent:* woensdag 20 januari 2021 12:20
> *To:* Bhattacharjee, Soumik <soumik(dot)bhattacharjee(at)kpn(dot)com>
> *Cc:* pgsql-admin(at)postgresql(dot)org
> *Subject:* Re: Data Type to store Leading Zero(0)
>
>
>
> Use datatype smallint(1) for storing zero or use Boolean datatype.
>
>
>
> On Wed, Jan 20, 2021, 4:43 PM <soumik(dot)bhattacharjee(at)kpn(dot)com> wrote:
>
> Hello Experts,
>
>
>
> As per business needs we need to store Zero(0) in primary key column of
> table with this kind of value à 07******** with applications written in
> Java microservices.
>
>
>
> We are not able to use *numeric data type *as it trims the Zero value in
> leading, but it’s also a performance impact if we define *varchar* in the
> data type.
>
>
>
> Please suggest.
>
>
>
> Thanks
>
>
>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Imre Samu 2021-04-16 13:08:26 Re: Data Type to store Leading Zero(0)
Previous Message soumik.bhattacharjee 2021-04-16 12:41:10 RE: Data Type to store Leading Zero(0)