我想用数据库中每个表的行数更新我自己在数据库中创建的行数表(postgres)
所以我正在尝试这样的事情,但它不起作用该功能正在将每行的计数替换为 0
CREATE OR REPLACE FUNCTION "update_row_counts" (reltuples integer, relname text)
RETURNS "pg_catalog"."void" AS
$body$
DECLARE
BEGIN
EXECUTE 'UPDATE row_counts set reltuples=' || reltuples || ' where relname = ''' || relname;
END;
$body$ LANGUAGE 'plpgsql';
SELECT update_row_counts(reltuples, relname),relname, reltuples FROM pg_class pg, information_schema.tables i where
pg.relname = i.table_name and relkind='r' and table_schema not in ('pg_catalog', 'information_schema');
谁能帮我