DO $$ DECLARE names CURSOR FOR select * from pg_tables where schemaname='riskzoning' and tablename like '%_clip' ; BEGIN FOR stmt IN names LOOP EXECUTE 'DROP TABLE '|| quote_ident(stmt.tablename) || ' CASCADE;'; END LOOP; END;$$
使用正则匹配表
select * from pg_tables where schemaname='riskzoning' and tablename SIMILAR TO '%_\d{13}' ;
结果 : 匹配 xzq_gw_50108_1651054276357