2017-07-19 50 views
0

当我运行我的命令:PSQL运行SQL文件,结果

psql -h localhost -p 5432 -U meee -d my_db -f sqltest.sql 

它显示:

CREATE VIEW 
ALTER TABLE 

但是我希望它告诉我,就像pgAdmin的表现出来(对于exmpl:查询是在45毫秒内成功执行,但不返回结果)

+0

'\ timing on':https://www.postgresql.org/docs/current/static/app-psql.html –

+0

哦谢谢。但没有任何改变 – Meegh

回答

0

在sqltest.sql的开头添加命令\ timing并且您将看到每个命令的时间

例如script.sql: \timing select 2 ; select 1; create table tablax(i int);

,或者如果你想让所有时间都弗洛姆德脚本,直到结束的开始时,添加一些命令scritp 的开始: create temp table tab (time1 time,time2 time); insert into tab (time1) select now()::time;

末: update tab set time2=now()::time; select time2-time1 as time_Elapsed from tab;

例如:

create temp table tab (time1 time,time2 time); 

insert into tab (time1) select now()::time;

... 脚本代码

... update tab set time2=now()::time; select time2-time1 as time_Elapsed from tab;