Creating a PostgreSQL sequence to a field (which is not the ID of the record)
Use CREATE SEQUENCE: CREATE SEQUENCE scores_job_id_seq; — = default name for plain a serial Then add a column default to scores.job_id: ALTER TABLE scores ALTER COLUMN job_id SET DEFAULT nextval(‘scores_job_id_seq’); If you want to bind the sequence to the column (so it is deleted when the column is deleted), also run: ALTER SEQUENCE scores_job_id_seq OWNED … Read more