这只是一般性准则,您需要在细节(特别是语法)方面进行工作。
您需要创建一个存储过程
information_schema.tables
为所需的表名创建一个循环检查过滤器
DECLARE
rec record;
strsql text;
BEGIN
FOR rec IN SELECT table_schema, table_name
FROM information_schema.tables
LOOP
strsql := strsql || 'SELECT ogc_fid, wkb_geometry FROM ' ||
rec.table_schema || '.' || rec.table_name || ' UNION ';
END LOOP;
-- have to remove the last ' UNION ' from strsql
strsql := 'SELECT row_number() over (ORDER BY a.ogc_fid) AS qid,
a.wkb_geometry AS geometry FROM (' || strsql || ')';
EXECUTE strsql;