In a PostgreSQL database I have a table with a primary key and another field which needs to be unique.
CREATE TABLE users ( id INTEGER PRIMARY KEY
If you need gapless sequences - there are ways to do it, but it's not trivial, and definitely much slower.
Also - if you worry about "using too many ids" - just define id as bigserial.