使用逗号分隔列表:
DROP TABLE foo,bar,baz;
如果你真的需要一个脚爪,这一个会做它的工作:
CREATE OR REPLACE FUNCTION footgun(IN _schema TEXT,IN _parttionbase TEXT) RETURNS void LANGUAGE plpgsql AS $$ DECLARE row record; BEGIN FOR row IN SELECT table_schema,table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = _schema AND table_name ILIKE (_parttionbase || '%') LOOP EXECUTE 'DROP TABLE ' || quote_ident(row.table_schema) || '.' || quote_ident(row.table_name); RAISE INFO 'Dropped table: %',quote_ident(row.table_schema) || '.' || quote_ident(row.table_name); END LOOP; END; $$; SELECT footgun('public','tablename');