1

I have a database (postgresql) with 10 schema and every schema has 10 tables. For some reasons, some tables do not have a primary key.

Is it possible to create a function/trigger that can look for all tables and

  • add a column id_pk serial (if the column does not exist)
  • and make it a primary key (if the table has not any primary key)?
peterh
  • 2,137
  • 8
  • 28
  • 41
Milad
  • 11
  • 1

0 Answers0