singmotor
singmotor

Reputation: 4180

Get a list of all schemas that contain a certain table name

I've looked at these questions:

But neither of them quite answer my question. I'm trying to search an entire PostgreSQL database and list the name of every schema in it that contains a "groups" table.

I'm thinking something like:

SELECT * FROM information_schema.tables WHERE table_name='groups';

But that's still missing how to get the containing schemas.

Upvotes: 0

Views: 1977

Answers (1)

Teja
Teja

Reputation: 13534

SELECT DISTINCT table_schema
  FROM information_schema.tables
 WHERE table_name='yourtablename'; 

Upvotes: 6

Related Questions