Re: Data Type to store Leading Zero(0)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nidhi Gupta <nidhig631@xxxxxxxxx> wrote:
> 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.


Use "integer" and define a view that pads the column with zeros on the
left side:

CREATE VIEW myview AS
SELECT lpad(if::text, 10, '0') AS id,
       othercolumn,
       ...
FROM mytable;

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux