i want to dynamically delete some tables from database. I select them first, and then i am trying to use delete statement but it doesn't works.
tmp TEXT;
FOR tmp IN SELECT names from Garbage
LOOP
DROP TABLE tmp;
END LOOP;
but unfortuntly i got errors at drop statement. It always trying to delete table "tmp" instead of deleting the value of tmp(which are some strings like "table1" "table2").
perform, i.e.perform drop table tmp::regclass. Better yet, use temporary tables -- they'll get dropped automatically at the end of your transaction.create temporary table .... That way, you don't need to be worry about garbage collecting it when you're done.