On 08/08/2019 16.38, Luca Ferrari wrote: > the first query is performed with quote_ident and that's the initial > failure. Oh now I get it, that was the reason why it wouldn't clone an existing schema! My schema names are always quoted and that's why it fails. I removed that quote_indent and it sort of works now (even though it still fails trying to do something on a nonexistant column!) I wonder how nobody noticed this before, while so many people discussed the script. As I'm not so good with procedural SQL, I wouldn't have caught it too. Many thanks! The other (main) problem is not solved yet, but we have gotten around it by simply removing the comment on triggers, which obviously confused the script. Without the comment, it works again; however it is obvious that the script still has problems which need to be addressed to be fully functional. I guess the script works fine with simpler names, but it seems the capital letters in our schema names (which require quoting where necessary) cause all the problems. Similar problem is present when PGAdmin tries to back such a schema up; the schema names require quoting (but that's a PGAdmin's problem, which I'll report elsewhere.) Thanks, A.K.