--编写test_2.sql脚本
[postgres@localhost ~]$ cat test_2.sql select * from test_2 where id=:v_id; 通过-v传递参数 [postgres@localhost ~]$ psql -v v_id=1 -f test_2.sql id ---- 1 (1 row)