'Domain for a char with only 5 digits. Postgresql

I want to create a domain in PostgreSQL for the insert of a code of only 5 digits (from 00000 to 99999). I want to keep all 0 before(int deletes 0 before other numbers) so that I can insert values like 00001.



Solution 1:[1]

Do a padding by the left of your numeric value that must be stored in a varchar field

select lpad(1::text,5,'0');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pepe N O