0

Is there a way to get all the schemas that exist on the DB server?

5
  • select * from information_schema.schemata but even though it has a column catalog_name you will never see a value that id different from the current database in there. Postgres does not support cross-database queries Commented Apr 5, 2016 at 7:34
  • and how to do this? I dev application in Java and have to get all schemas from specified database :c Commented Apr 5, 2016 at 7:41
  • Just run that statement, it will return all schemas. Commented Apr 5, 2016 at 7:42
  • Maybe you can achieve what you need with a combination of shell scripting and psql command. Can you expand on your requirements, type of output, and the consumer of the data? Commented Apr 5, 2016 at 8:55
  • I already solved this problem ,ty you guys Commented Apr 6, 2016 at 11:00

1 Answer 1

1
SELECT schema_name 
FROM information_schema.schemata 
WHERE schema_name NOT LIKE 'pg%'
AND schema_name NOT LIKE 'information_schema'
AND catalog_name LIKE 'YOUR_DATABASE_NAME'

Two NOT LIKE clauses are to avoid system schemas

Sign up to request clarification or add additional context in comments.

Comments

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.