SET @newproprio = 'ludodo';
SET @le_schema = 'spatial';

SET @idx=0;
set @count = select count(*) from pg_tables where schemaname = '@le_schema';
set @lestables = select tablename from pg_tables where schemaname = '@le_schema';

while @idx < @count[0][0]
begin
 set @latable = @lestables[@idx]['tablename'];
 ALTER TABLE @le_schema.@latable OWNER TO @newproprio;
 set @idx = @idx + 1;
end