Drop all data types in Postgres

Viewed 1063

Is there a way to drop all the data types listed by \dT+.

I know you can drop types individually via DROP TYPE command, but I have a lot of types and it's painstaking to drop them all individually.

1 Answers

Following the directions suggested by user Schwern, I used psql -E and got this to work:

  1. Run SELECT typname, typnamespace from pg_type;
  2. Figure out what typnamespace your types are associated with
  3. DELETE FROM pg_type WHERE typnamespace=${your_typnamespace}
Related