Sample Header Ad - 728x90

Alter all tables in schema to set an existing field as an IDENTITY PRIMARY KEY

0 votes
1 answer
101 views
Is there an easy and robust way to execute these two commands on all tables in a given schema myschema in a PostgreSQL (13) database:
ALTER TABLE myschema.table001 ADD PRIMARY KEY (oid);
ALTER TABLE myschema.table001 ALTER "oid" ADD GENERATED ALWAYS AS IDENTITY;
I'm 100% certain that the oid field is present in theses tables.
Asked by s.k (424 rep)
Mar 1, 2024, 10:02 AM
Last activity: Mar 1, 2024, 11:20 AM