Why doesn’t this work exactly?
ALTER TABLE IF EXISTS public.post ALTER COLUMN id TYPE INTEGER PRIMARY KEY OWNER to postgres;
The error is
syntax error at or near “PRIMARY”
Advertisement
Answer
The syntax for PostgreSQL is as follows :
Try with this:
ALTER TABLE IF EXISTS public.post ADD PRIMARY KEY (id);
Documentation : https://www.postgresqltutorial.com/postgresql-primary-key/