From: | <soumik(dot)bhattacharjee(at)kpn(dot)com> |
---|---|
To: | <Anssi(dot)Kanninen(at)digia(dot)com>, <pgsql-admin(at)postgresql(dot)org>, <nidhig631(at)gmail(dot)com> |
Subject: | RE: Data Type to store Leading Zero(0) |
Date: | 2021-01-20 11:32:13 |
Message-ID: | 49825a434d264d58b4a02e0b97925272@kpn.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Thanks , will test this both as need to check the entity mappings from my Java spring boot.
From: Kanninen Anssi EXT <Anssi(dot)Kanninen(at)digia(dot)com>
Sent: woensdag 20 januari 2021 12:29
To: pgsql-admin(at)postgresql(dot)org
Subject: RE: Data Type to store Leading Zero(0)
Hi,
How about storing the actual number in TEXT column and adding a separate INT primary key column where you either copy the number or use it as a generated column?
Or, if you actually want to include the leading zeroes in the primary key, how about two-column primary key like this:
number_of_leading_zeroes smallint,
the_number integer
So, the number "0005556879" would become a primary key (3, 5556879).
Sincerely,
Anssi Kanninen
From: Nidhi Gupta <nidhig631(at)gmail(dot)com<mailto:nidhig631(at)gmail(dot)com>>
Sent: keskiviikko 20. tammikuuta 2021 13.20
To: soumik(dot)bhattacharjee(at)kpn(dot)com<mailto:soumik(dot)bhattacharjee(at)kpn(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org<mailto: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<mailto: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
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Lawrence Barwick | 2021-01-20 11:36:50 | Re: 3 Parameters in pg_settings in CamelCase |
Previous Message | Kanninen Anssi EXT | 2021-01-20 11:29:18 | RE: Data Type to store Leading Zero(0) |