postgres 操作记录总数汇总mark

pg里有时候会存在数据删除操作需要查看到底有多少条数据被删除,这时候通过下面方法会比较简单

mrapp=# create temp table _tt (id int) ;

CREATE TABLE

时间:615.655 ms

mrapp=# insert into _tt select generate_series(1,100);

INSERT 0 100

时间:28.483 ms

mrapp=# do

mrapp-# $$

mrapp$# declare

mrapp$# v_count int ;

mrapp$# begin

mrapp$# delete from _tt where id > 44;

mrapp$# get diagnostics v_count = ROW_COUNT ;

mrapp$# raise notice 'delete count :%' , v_count;

mrapp$# end;

mrapp$# $$;

NOTICE:  delete count :56

DO

时间:45.969 ms

猜你喜欢

转载自jjxliu306.iteye.com/blog/2192787
今日推荐