I want to run this SQL on the local and remote host:
select concat_ws('.', table_schema, table_name, column_name) as column_name from information_schema.columns where table_schema not in ('information_schema', 'pg_catalog') order by table_schema, table_name, ordinal_position;
The above SQL gets called via
psql -c "..."
psql command on the remote host gets called via
ssh remote-host psql ...
Then I want to compare the remote and local result with
Trying to do this with the shell drives me crazy since the quoting is not trivial.
Is there a tool which can help here?
compare-with-remote foo@remote-host psql -c "SELECT ..."
The tool should be universal (not just for psql).
Yes, I know this could be done with the shell in one big ugly command line, but I search a clean, simple and readable solution where I don't need to escape quote chars.
I know how to do this interactively with the bash shell in several steps. I have done comparisons like this several time during the last years. Sometimes I call psql sometimes other commands.
Background: The above SQL outputs the tables and the columns in ordinal_position. Related. https://dba.stackexchange.com/questions/120715/compare-order-of-columns-between-two-databases