There is no good performance solution for a gap-less sequence. At a minimum you need to store the sequence on a table and lock the row (or table) on each access until the transaction commits. Gaps are normal and expected with sequences. It is best to get used to, accept it, and move-on. You can of course create a view that derives the version on the fly. See example.
create view type_view as
select id, type_cd, row_number() over (partition by type_cd) as version
from type_data
order by id;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…