Yes, of course, but such a functionality typically clashes with the logic of an interactive multiuser/multithreaded application that would ideally produce immediate results. If this is not your case, then a simple trigger is the solution.
On the other hand, if you need immediate results, read on. You would probably need to implement delayed processes that assign these numbers in an orderly manner instead of doing it interactively when each row is inserted in a table. For example, you could record every new data insertion in a "pending" table or queue for further processing.
There are many options but off the top of my head you could:
- Use a process behind the scenes that will run every 5 minutes, and processes all pending rows.
- If you use a queue then you can have a reactive process that is continually running and waiting for rows to process and assign numbers, one at a time.
- You can even delay all number assignation for the nightly process if that's an option.
For higher performance, you can implement any solution above in parallel, even in separate hardware if you are able to partition the data somehow. For example all IDs ending in 01-03
(partition #1) will be processed by node/process #1, then IDs ending in 04-07
(partition #2) could be processed by node/process #2 and so on.
As you see there's nothing built-in in the database for your use case, but there are plenty of good solutions for it, if you can relax some contraints, like perform the number assignation with a 5-minute delay.