Em 4 de fevereiro de 2014 17:09, [email protected] < [email protected]> escreveu:
> Boa tarde, > > Quero excluir views que estão em um campo de uma tabela. > > como se fosse > > drop view (select campo from tabela); > > e excluir todas as views que contém no campo. > > tem como? > > Att, > > Erlon > > _______________________________________________ > pgbr-geral mailing list > [email protected] > https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral > > cara veja se te ajuda, achei no google e ajustei.. BEGIN TRANSACTION; DO $$DECLARE r record; DECLARE s TEXT; BEGIN FOR r IN select c.table_schema,c. table_name from information_schema.tables t inner join information_schema.columns c on c.table_catalog = t.table_catalog and c.table_schema = t.table_schema and c.table_name = t.table_name left join information_schema.key_column_usage u on c.table_catalog = u.table_catalog and c.table_schema = u.table_schema and c.table_name = u.table_name and c.column_name = u.column_name where t.table_type='VIEW' and c.table_schema not like '%pg%' and c.table_schema ='dah' C.COLUMN_NAME like 'hash%' group by 1,2 LOOP s := 'DROP VIEW ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ';'; EXECUTE s; RAISE NOTICE 's = % ',s; END LOOP; END$$; ROLLBACK TRANSACTION; ajuste alterando o schema, campo e faça numa tabela de teste -- Douglas Fabiano Specht
_______________________________________________ pgbr-geral mailing list [email protected] https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
