I have a table in my database that is in dire need of an auto-incrementing field. To create one, I ran these following SQL statements towards the aforementioned database:
CREATE SEQUENCE table_id_seq
INCREMENT 1
NO MINVALUE
NO MAXVALUE
START 1
CACHE 1;
ALTER TABLE ONLY table ALTER COLUMN id SET DEFAULT nextval('table_id_seq'::regclass);
ALTER TABLE ONLY table
ADD CONSTRAINT table_id PRIMARY KEY (id);
However, when I try to INSERT any two values into table I still get a primary key violation error. I don't understand what I'm missing to make it auto-incrementing.