admin
|
|
[运营交流]
停止指定数据库上所有正在执行的SQL(Postgresql)
添加语言 create language plpgsql;
创建函数 CREATE OR REPLACE FUNCTION cancelQueryByDBName( dbname TEXT ) RETURNS void as $$ DECLARE var_procpid integer; BEGIN FOR var_procpid IN SELECT procpid FROM pg_stat_activity where datname = dbname and current_query <> '<IDLE>' order by procpid LOOP PERFORM pg_cancel_backend(var_procpid); END LOOP; END; $$ language plpgsql;
执行函数,停止执行中的sql select cancelQueryByDBName('dbname');
|
|
|
发帖时间:2015-12-28 |
查看数:0 |
回复数:0
|