0

I have a database with an old broken version of PostGIS installed in it. I would like to easily drop all views in the database (they're all from PostGIS). Is there a simple way to do this? Even simply extracting a list of views names would be acceptable as I could just make a large DROP VIEWS statement.? Thanks In Advance

1 Answer 1

2

This should give you a set of view names in the public schema. Replace 'sandbox' with the name of your database.

select table_name
from information_schema.views
where table_catalog = 'sandbox'
  and table_schema = 'public'
Sign up to request clarification or add additional context in comments.

1 Comment

+1, and Satish can wrap this up into a PL/PgSQL function using EXECUTE, string_agg and quote_ident to make a simple function to drop all views. S: To find out how, just do some searching, there are plenty of answers here that explain EXECUTE, format, etc.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.