Answer the question
In order to leave comments, you need to log in
How to create a sixty-two sequence in postgresql?
Good day. Can you tell me how to create a sequence with base 62 for the primary key in postgresql? That is, for example, the first record in the table will be with ID="1", the 35th record - ID="Z", the 287th record - ID="4d", the 13777th record - ID="3aD" etc. Thanks in advance for your reply.
Answer the question
In order to leave comments, you need to log in
Make a function to convert int to 62base text
Make a regular SEQUENCE
and default int_to_62base(nextval('lala_seq'::regclass))
And for good, there is no way to create an ASCII table using text characters.
There are only 36 characters for letters and numbers, so you have to break off
>>> int("1234567890",62)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: int() base must be >= 2 and <= 36
>>> int("1234567890",36)
107446288850820L
>>>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question