0

I have two databases new_site,old_site I'm connecting to the database server via Postgres user and have full permission and I connect to new_site db.

I need to get tables names for old_site so I tried this:

SELECT table_name 
FROM information_schema.tables 
WHERE table_catalog = $$old_site$$;

but I get a null as result.

If I run this query:

SELECT table_name 
FROM information_schema.tables 
WHERE table_catalog = current_database();

I get back the table name and it works.

I expect the output is table name of old_site db, how can I do this?

I was also reading some solutions here like: Selecting column name from other database table through function in PostgreSQL

But it's not like my case.

2
  • 2
    You can't query other databases in Postgres directly. Only through e.g. a foreign data wrapper or the dblink module. Commented Oct 20, 2021 at 6:12
  • @a_horse_with_no_name, what do you mean ? can you explain please Commented Oct 20, 2021 at 7:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.