I am using PostgreSQL and I need to remove an index without knowing its name.
I have multiple instances where the index was created using Liquibase script. I want to drop the indexes created and add a new index.
I have a script that would give me the Drop statements.
select format('drop index %I.%I;', schemaname, indexname) as qry
from pg_indexes
where schemaname not in ('pg_catalog', 'pg_toast')
and tablename='table_name'
and indexname!='table_name_pkey'
But I am not sure how to use the result set to drop the inedexes.
Executing using SQL Shell/ Liquibase where I can add SQL Statements. Cant make long functions to do that.