Repeat an action for X number of PostgreSQL tables

by Kapten-N   Last Updated July 17, 2017 10:06 AM

Note: The solution does not need be optimised for processing speed. It's supposed to be part of a setup phase and won't be run more than once.

General problem

I have X number of tables in a PostgreSQL database with very different names. I can neither be bothered to write the same PostgreSQL commands for each of them, nor can I be sure that the next set of data that I import has the exact same set of tables. Yet I would like to repeat the same action on each of them. How would I go about doing this? Is it even possible?

I will accept an answer that can do this much. However, an answer that does this and also allows me to exclude some tables that I do know the names of would be even better.

Specifics

This question is closely related to another question which details what I want to do with the tables, but both specific and more general answers are appreciated.

Findings

While looking for a solution I found this question, but I don't know if and how I could use those answers. I'm including it here in hopes that someone else might know how to apply them to my question.



Related Questions


Postgres gist slow index f_unaccent

Updated April 09, 2018 20:06 PM