nomad
nomad

Reputation: 1778

In PostgreSQL, how do you find all the tables that are using a specific enum type?

Error : ERROR: cannot drop type some enum type because other objects depend on it

How do I know which objects depend on it?

Upvotes: 3

Views: 1210

Answers (2)

Oliver
Oliver

Reputation: 1645

Here is a modified version of the first answer, but also finds columns with array types:

select
  c.table_name,
  c.column_name
from information_schema.columns as c
where
  (data_type = 'USER-DEFINED' and udt_name = 'my_type')
  or (data_type = 'ARRAY' and udt_name = '_my_type'); -- The leading `_` is required.

Upvotes: 1

nomad
nomad

Reputation: 1778

SELECT table_name, column_name from INFORMATION_SCHEMA.columns
WHERE data_type = 'USER-DEFINED' AND udt_name = 'my enum type name'

Upvotes: 9

Related Questions